【问题标题】:Getting exception while Consuming https Webservice in mule在 mule 中使用 https Webservice 时出现异常
【发布时间】:2014-06-28 15:10:52
【问题描述】:

我正在尝试在 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 服务。我遇到了上述异常。

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

Mule 配置 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; 字符串 serviceUrl = "TARGET_HTTPS_WSDL"; //这将是目标 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());

返回响应.getMessage();

【问题讨论】:

  • 您能否分享您的流程以检查导致问题的原因
  • 我已将详细信息添加到我发布的问题中。如果您需要更多详细信息,请告诉我。

标签: https cxf mule


【解决方案1】:

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

还有一件事..您需要使用 java 组件而不是 &lt;custom-transformer class ..您需要在组件之前设置有效负载...我的意思是您需要在将有效负载发布到外部 web 服务之前设置有效负载

【讨论】:

  • Thnx Anirban。但是我们计划集成一个库,它将使用 CXF 客户端代理调用 https。根据业务流程,将有多个对不同 WS 的 https 调用。这个 Mule 是我们在进一步实施之前尝试验证的 POC。我们尝试了 Mule “使用 JAX-WS 客户端 API” 推荐的方法,但它不适用于 https 调用。
  • Mule 是一个很好的平台来托管服务以及使用外部服务.. 使用 Mule 您可以以非常简单的方式调用多个服务...您只需要正确配置...就是这样...在您的流程中,您配置错误..应该有一个 http:inbound 端点、一个 set 有效负载、一个 cxf:jaxws-client 和一个 http:outbount 端点来发布数据..就是这样全部 。请参考以下 2 个链接:- training.middlewareschool.com/mule/…training.middlewareschool.com/mule/consuming-wsdl-first-service ...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-17
相关资源
最近更新 更多