在mule中使用https Webservice时获取异常

时间:2014-06-28 15:10:52

标签: https cxf mule

我试图在Mule中使用cxf生成的客户端代理来调用https Web服务。几乎99%的时间,我得到

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

该应用有http入站终点。 Mule Java转换器尝试使用cxf生成的客户端代理使用https调用Web服务。我遇到了上述异常。

我提供了骡子流[http://i.stack.imgur.com/7X9Wg.jpg]的屏幕截图。非常感激!!

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>

变压器 URL wsdlURL = null; String serviceUrl =&#34; TARGET_HTTPS_WSDL&#34 ;; //这将是目标https网址

    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 个答案:

答案 0 :(得分:0)

首先,如果您需要使用网络服务您需要放置<cxf:jaxws-client serviceClass而不是cxf:jaxws-client ...下一步是您需要使用 http出站端点发布到外部Web服务...请参阅以下链接: - http://www.mulesoft.org/documentation/display/current/Consuming+Web+Services+with+CXF

还有一件事......你需要使用java组件而不是<custom-transformer class ..你需要在组件之前设置有效负载......我的意思是你需要在将有效负载发布到外部webservice之前设置它

相关问题