e2rabi
e2rabi

Reputation: 4838

Apach cxf soap wsdl without complexType

I create a soap web service using apache cxf ,whenI publish my web service I get a WSDL without complex Type section , this's my code :

My Interafce :

@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;
}

My configuration :

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

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

        return endpoint;
    }

My request object :

@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 ;
   

}

And this's the WSDL generated :

<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>

Why In my generated WSDL i can't find my request attributes like "referenceNumber"

Upvotes: 2

Views: 452

Answers (1)

Bogdan
Bogdan

Reputation: 24580

Check the imported WSDL to see if the request object is defined there. Look at this line in your WSDL:

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

If you open http://localhost:8082/home/GetAuthorizationDetails/V4?wsdl=IGetAuthorizationDetails.wsdl in your browser what does it contain? Is your type and reference number in there?

Finally, I would try to use only one XML namespace in defining the web service and all its component elements. Right now you have two namespaces from what I see:

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

... and CXF is creating the WSDL in two parts. Using one namespace should give you one complete WSDL with no imports and just one URL to use. See also: CXF autogenerates WSDL imports itself?

Upvotes: 2

Related Questions