【问题标题】:Apach cxf soap wsdl without complexType没有 complexType 的 Apache cxf soap wsdl
【发布时间】:2021-04-09 10:22:06
【问题描述】:

我使用 apache cxf 创建了一个肥皂网络服务,当我发布我的网络服务时,我得到一个没有复杂类型部分的 WSDL,这是我的代码:

我的界面:

@WebService(targetNamespace = "http://v4.ws.provider.acp.com/", name = "IGetAuthorizationDetails")
public interface IGetAuthorizationDetailsWebService {

    @WebMethod(operationName = "getAuthorizationDetailsV4")
    @RequestWrapper(localName = "getAuthorization_V4", targetNamespace = "http://request.message.provider.acp.com/", className = "ws.model.request.GetAuthorizationDetailsV4")
    @ResponseWrapper(localName = "getAuthorizationDetails_V4Response", targetNamespace = "http://response.message.provider.acp.com/", className = "ws.model.response.GetAuthorizationDetails4Response")
    @WebResult(name = "GetAuthorizationDetailsV4Rs", targetNamespace = "")
    public GetAuthorizationDetailsV4Rs getAuthorizationDetails4(

            @WebParam(name = "GetAuthorizationDetailsV4Rq", targetNamespace = "")
            @Valid GetAuthorizationDetailsV4Rq request
    ) throws TechnicalException;
}

我的配置:

  @Bean
    public ISearchAuthorizationWebServicePort getISearchAuthorizationWebServicePort(){
        return new ISearchAuthorizationWebServicePort();
    }

@Bean
    public Endpoint getIGetAuthorizationDetailsEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus,  getIGetAuthorizationDetailsWebServicePort());
        endpoint.publish("/GetAuthorizationDetailsTest/V4");

        return endpoint;
    }

我的请求对象:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "GetAuthorizationDetailsV4Rq", namespace = "http://request.message.provider.acp.com/", propOrder = {
        "referenceNumber",
})
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper=false)
public class GetAuthorizationDetailsV4Rq extends AbstractMessageV4Rq {

    @XmlElement(name = "referenceNumber")
    @Pattern(regexp = "^[A-Za-z0-9]*$", message = "ReferenceNumber must contains only alphanumeric characters")
 private String referenceNumber ;
   

}

这是生成的 WSDL:

<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.api.controller.ws/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns4="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://v4.ws.provider.acp.com/" name="IGetAuthorizationDetailsWebServicePortService" targetNamespace="http://ws.api.controller.ws.pwc/">
<wsdl:import location="http://localhost:8082/home/GetAuthorizationDetails/V4?wsdl=IGetAuthorizationDetails.wsdl" namespace="http://v4.ws.provider.acp.com/"> </wsdl:import>
<wsdl:binding name="IGetAuthorizationDetailsWebServicePortServiceSoapBinding" type="ns1:IGetAuthorizationDetails">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAuthorizationDetailsV4">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getAuthorizationDetailsV4">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getAuthorizationDetailsV4Response">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="TechnicalException">
<soap:fault name="TechnicalException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="IGetAuthorizationDetailsWebServicePortService">
<wsdl:port binding="tns:IGetAuthorizationDetailsWebServicePortServiceSoapBinding" name="IGetAuthorizationDetailsWebServicePortPort">
<soap:address location="http://localhost:8082/home/GetAuthorizationDetails/V4"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

为什么在我生成的 WSDL 中找不到像“referenceNumber”这样的请求属性

【问题讨论】:

  • 您在哪里定义了referenceNumber 字段?是错字吗? GetAuthorizationDetailsV4Rq 中似乎没有包含它。
  • 我更新了我的代码我添加了字段

标签: java spring soap jaxb cxf


【解决方案1】:

检查导入的 WSDL 以查看是否在此处定义了请求对象。查看 WSDL 中的这一行:

<wsdl:import location="http://localhost:8082/home/GetAuthorizationDetails/V4?wsdl=IGetAuthorizationDetails.wsdl" namespace="http://v4.ws.provider.acp.com/"> </wsdl:import>

如果您在浏览器中打开http://localhost:8082/home/GetAuthorizationDetails/V4?wsdl=IGetAuthorizationDetails.wsdl,它包含什么?里面有你的型号和参考号吗?

最后,我将尝试仅使用一个 XML 命名空间来定义 Web 服务及其所有组件元素。现在你有两个我看到的命名空间:

http://request.message.provider.acp.com/
http://v4.ws.provider.acp.com/

... CXF 分两部分创建 WSDL。使用一个命名空间应该为您提供一个完整的 WSDL,无需导入,只需使用一个 URL。另见:CXF autogenerates WSDL imports itself?

【讨论】:

  • 当我使用你的网址时,我的 wsdl 包含所有对象类型!如何在默认情况下将此 url 设置为目录 wsdl 中的默认 url 我得到此 url localhost:8082/home/GetAuthorizationDetails/V4?wsdl
  • @e2rabi:您的默认 URL 应该可以工作,即使它包含来自其他地方的部分。所以上面生成的WSDL就可以了。如果您只想要一个 URL,请参阅我的更新答案。
  • 非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多