Reputation: 207
I am attempting to consume a wsdl service using cfx:proxy-client in Mule ESB 3.3 but keep getting this error
org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://support.cxf.module.mule.org/}ProxyService. at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:139) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:383) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:506)
Below is my simple flow:
<flow name="spider-middleware" doc:name="spider-middleware"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="salesforce" doc:name="HTTP"/> <cxf:proxy-client operation="getCustomerByID" payload="body" wsdlLocation="http://localhost:4546/eplus-ws-fake/services/EplusCustomer/v1?wsdl" enableMuleSoapHeaders="true" doc:name="SOAP"/> </flow>
The service is hardcoded to return a customer for getCustomerByID(1). Please shed some lights on how do I get around the issue? Thanks.
Upvotes: 1
Views: 3231
Reputation: 33413
I got it working but only by providing a full SOAP envelope and not just the body, ie. using payload="envelope"
.
Also I removed the operation
and wsdlLocation
attributes, which are useless for the proxy-client
. I also had to add SOAPAction
and Content-Type
properties, otherwise the test webservice I'm using chokes on the request.
This gives (using a test service from WebServiceX.net):
<flow name="pureCxfProxyClient">
<vm:inbound-endpoint path="test.in"
exchange-pattern="request-response" />
<set-property propertyName="SOAPAction"
value="http://www.webservicex.net/getACHByZipCode" />
<set-property propertyName="Content-Type" value="text/xml" />
<http:outbound-endpoint address="http://www.webservicex.net/FedACH.asmx"
exchange-pattern="request-response" >
<cxf:proxy-client payload="envelope" />
</http:outbound-endpoint>
</flow>
Note I used a VM endpoint, which allowed me to deal with the XMLStreamReader
returned by the cxf:proxy-client
.
In particular, I needed to do the following:
final XMLStreamReader xsr = (XMLStreamReader) result.getPayload();
xsr.nextTag();
to avoid crazy NPEs in org.mule.module.xml.stax.ReversibleXMLStreamReader
.
All in all this is pretty intense... plus the cxf:proxy-client
doesn't deliver much value when used standalone. You could actually just go with:
<flow name="pureCxfProxyClient">
<vm:inbound-endpoint path="test.in"
exchange-pattern="request-response" />
<set-property propertyName="SOAPAction"
value="http://www.webservicex.net/getACHByZipCode" />
<set-property propertyName="Content-Type" value="text/xml" />
<http:outbound-endpoint address="http://www.webservicex.net/FedACH.asmx"
exchange-pattern="request-response" />
</flow>
... and be freed of the XMLStreamReader
part.
Upvotes: 3