0
votes

I am trying to consume web service using CXF component in mule(Anypoint Studio). So I tried genrating the WSDL file from URL but I was getting this errror: Rpc/encoded wsdls are not supported in CXF so I followed this answer.

It worked and it generated client stubs, then copied the files into my mule project.

but I am getting this error:

Service.SomeService.<init>(java.net.URL, javax.xml.namespace.QName) (java.lang.NoSuchMethodException)

This is my flow:

<flow name="WebServiceTest">
          <cxf:jaxws-client
         clientClass="service.SomeService"
         wsdlLocation="http://127.0.0.1:8000/api/v2_soap/?wsdl"
        operation="test"/>         
      <outbound-endpoint address="http://127.0.0.1:8000/api.php/?type=v2_soap"/>
</flow>

Any ideas?

1

1 Answers

0
votes

Your configuration is not correct specially your outbound endpoint url. You can try configuring a CXF client as per Mule documentation.
You can also build a client for your JAX-WS services without generating a client from WSDL. Here you need a copy of your service interface and all your data objects locally to use something like this :-

<flow name="csvPublisher">
  ...
  <cxf:jaxws-client serviceClass="org.example.HelloService" operation="sayHi"/>
  <outbound-endpoint address="http://localhost:63081/services/greeter"/>
</flow>

Another approach is you can use a CXF-generated client as an outbound endpoint. First, you need to generate a CXF client using the WSDL to Java tool from CXF or the Maven plugin.
Then you need to configure something like the following :-

<flow name="csvPublisher">
  ...
  <cxf:jaxws-client
         clientClass="org.apache.hello_world_soap_http.SOAPService"
         port="SoapPort"
         wsdlLocation="classpath:/wsdl/hello_world.wsdl"
         operation="greetMe"/>
  <outbound-endpoint address="http://localhost:63081/services/greeter"/>
</flow>

It is better to put the wsdl in your local classpath.

Please checkout the full documentation here as reference to get it configured :-
https://docs.mulesoft.com/mule-user-guide/v/3.7/consuming-web-services-with-cxf
and
Consuming a Webservice Using Mule 3.4