0
votes

I'm trying to call a https web service using cxf generated client proxies within Mule. Almost 99% of the time, I get

Caused by: org.apache.commons.httpclient.ProtocolException: Unbuffered entity enclosing request can not be repeated. at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:487) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)*

The app has http inbound end point. The Mule Java transformer tries to call a webservice using https using cxf generated client proxies. I'm running into above said exception.

I've provided screenshot the mule flow [http://i.stack.imgur.com/7X9Wg.jpg]. Much appreciated!!

Mule config xml

<cxf:jaxws-service serviceClass="test.service.https.TestService" doc:name="SOAP" configuration-ref="CXF_Configuration" enableMuleSoapHeaders="false"/>
<custom-transformer class="test.service.https.CallLicenseService" doc:name="Calls HTTPS WS using CXF generated client proxies" encoding="UTF-8" mimeType="text/plain"/>
<logger message="Success" level="INFO" doc:name="Logger"/>
<set-payload value="#['HELLO SUCCESS']" doc:name="Set Payload"/> </flow>

Transformer URL wsdlURL = null; String serviceUrl = "TARGET_HTTPS_WSDL"; //This would be the target https URL

    try {
        wsdlURL = new URL(serviceUrl);
    } catch (MalformedURLException e) {
        Logger.getLogger(getClass()).info("", e);
    }

    AuditLogServiceService ss = new AuditLogServiceService(wsdlURL);
    AuditLoggingService port = ss.getAuditLoggingServicePort();
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
            serviceUrl.substring(0, serviceUrl.length() - 5));
    AuditLogServiceRequest request = new AuditLogServiceRequest();
    request.setClientId("4");
    request.setUserId("101");
    request.setEventSubType("1");
    request.setEventType("1");
    AuditLogMessage msg = new AuditLogMessage();
    msg.setMessage("Hello Test");
    request.getLogMessages().add(msg);
    AuditLogServiceResponse response = port.logEvent(request);
    System.out.println(response.getMessage());

return response.getMessage();

1
Could you pls share your flow to check what is causing the issue - Anirban Sen Chowdhary
I've added the details to the question I've posted. Pls let me know, if you need more details. - Ayyappan M

1 Answers

0
votes

First of all if you need to consume a webservice You need to put <cxf:jaxws-client serviceClass instead of cxf:jaxws-client ...next step is you need to use an http outbound endpoint to post to the external webservice ... pls refer the following link :- http://www.mulesoft.org/documentation/display/current/Consuming+Web+Services+with+CXF

One more thing .. you need to use java component instead of <custom-transformer class ..you need to set the payload just before the component ... I mean you need to set the payload before posting it to external webservice