【问题标题】:MULE ESB - simple jaxws client don't work ... - Message payload is of type: ContentLengthInputStreamMULE ESB - 简单的 jaxws 客户端不起作用... - 消息有效负载类型:ContentLengthInputStream
【发布时间】:2014-08-19 15:07:32
【问题描述】:

大家好,首先我想让你们看看我的 wsdl 文件,它是 DHL24 api,我想了解一下这方面的知识并使用简单的例子,这里是链接 https://dhl24.com.pl/webapi.html

我想使用 getVersion,如您所见,我们不需要为此提供任何数据,仅作为响应我们有 getVersionResult - STRING

首先,我使用简单项目创建了从 apache CTX 生成的包,这里是 POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.test</groupId>
<artifactId>DhlServiceClient</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <apache.cxf-version>2.5.9</apache.cxf-version>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${apache.cxf-version}</version>
            <executions>
                <execution>
                    <id>Wsdl2Java - gasShopService.wsdl</id>
                    <phase>generate-sources</phase>
                        <configuration>
                        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/resources/dhlService.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-autoNameResolution</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>pl.test</extraarg>
                                    <extraarg>-aer=false</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-frontend</extraarg>
                                    <extraarg>jaxws21</extraarg>
                                    <extraarg>-wsdlLocation </extraarg>
                                    <extraarg>classpath:dhlService.wsdl</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这里一切都很好,我有包和类,所以我开始创建第二个项目(作为依赖项,我添加了这个包 - 这很好用)

现在我想创建简单的流程:

<flow name="getVersion" doc:name="getVersion">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>

<logger doc:name="getVersion" message="Test Before" level="ERROR"/>
<cxf:jaxws-client operation="getVersion" clientClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>

<logger doc:name="getVersion" message="Test after" level="ERROR"/>
</flow>

没什么大不了的,但是当我发布到这里时,我有:

错误 2014-06-28 20:36:10,289 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor:错误前测试 2014-06-28 20:36:10,291 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: ****************************************************** ***************************** 消息:参数数量错误。路由失败 通过端点的事件:org.mule.module.cxf.CxfOutboundMessageProcessor。 消息负载的类型:ContentLengthInputStream 代码
: MULE_ERROR--2 -------------------------------------------------- ------------------------------ 异常堆栈是: 1. 参数数量错误(java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null) 2. 参数数量错误。无法通过端点路由事件:org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效负载是 类型:ContentLengthInputStream (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 -------------------------------------------------- ------------------------------ 根异常堆栈跟踪:java.lang.IllegalArgumentException:错误 参数数量 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) + 3 个以上(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 为所有内容)


我在谷歌搜索了一下,发现了类似的东西。我在入站后添加:

<object-to-byte-array-transformer />

我还有其他错误:

错误 2014-06-28 20:45:18,149 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor:错误前测试 2014-06-28 20:45:18,151 [[gaspoldhlservice].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: ****************************************************** ***************************** 消息:参数数量错误。路由失败 通过端点的事件:org.mule.module.cxf.CxfOutboundMessageProcessor。 消息有效负载类型为:byte[] 代码: MULE_ERROR--2 -------------------------------------------------- ------------------------------ 异常堆栈是: 1. 参数数量错误(java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null) 2. 参数数量错误。无法通过端点路由事件:org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效负载是 类型:byte[] (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 -------------------------------------------------- ------------------------------ 根异常堆栈跟踪:java.lang.IllegalArgumentException:错误 参数数量 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) + 3 个以上(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 为所有内容)


我需要一点点推这里它非常简单的方法,我不能正确处理它......

编辑后:

更改为您的流程:

<flow name="getVersion" doc:name="getVersion">
   <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>


<cxf:jaxws-client operation="getVersion" serviceClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>

<http:outbound-endpoint exchange-pattern="request-response"  address="http://localhost:8088/consumeTest" doc:name="HTTP" method="POST"/>

</flow>

<flow name="consumeTest" doc:name="consumeTest">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="consumeTest" doc:name="HTTP"/>
    <logger doc:name="getVersion" message="Test AFTER" level="ERROR"/>
</flow>

答案是

没有这样的操作:getVersion。无法通过端点路由事件: org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效负载是 类型:ContentLengthInputStream

当我使用 clientClass 而不是 serviceClass 时:

参数数量错误。无法通过端点路由事件: org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效负载是 类型:ContentLengthInputStream

【问题讨论】:

    标签: java web-services mule esb mule-studio


    【解决方案1】:

    您需要在cxf:jaxws-client 之后放置一个出站端点,例如 &lt;http:outbound-endpoint exchange-pattern="request-response" address="Your external webservice path that you are tying to consume " doc:name="HTTP" method="POST"/&gt; 将值发布到外部网络服务 .. 例如,如果您的外部网络服务位于 http://localhost:8086/mainData?wsdl,那么您需要放置

    &lt;http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8086/mainData" doc:name="HTTP" method="POST"/&gt; ......还有一件事......你能改变一下吗 &lt;cxf:jaxws-client operation="getVersion" clientClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP"&gt;

    `<cxf:jaxws-client operation="getVersion" serviceClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">`  in your flow and try ...
    

    所以最终流程应该是这样的:-

     <flow name="getVersion" doc:name="getVersion">
            <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>
    
    
        <cxf:jaxws-client operation="getVersion" serviceClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
        </cxf:jaxws-client>
    
        <http:outbound-endpoint exchange-pattern="request-response"  address="Your external webservice path that you are tying to consume " doc:name="HTTP" method="POST"/>
        </flow>
    

    【讨论】:

    • 更改为评论中的流程后仍然无法正常工作
    • 编辑错误 getVersion 流程中的 http:outbound-endpoint 应该有指向您喜欢使用的外部 web 服务的地址...例如 ..如果已经有外部 web 服务可用在localhost:8088/consumeTest 并且您喜欢消费,那么流程将正常工作.. 否则,如果没有这样的外部 Web 服务可用,那么您需要在另一个流程中公开外部服务,然后在您的 http:outbound 中使用该地址-getVersion 流的端点...这里的流消费测试应该充当您喜欢使用的外部 Web 服务
    • 这里是构建外部 Web 服务的示例:-mulesoft.org/documentation/display/current/… ...您需要创建另一个流程,就像您创建了 consumeTest 并在该流程中公开该 Web 服务 ...
    • 创建一个外部 web 服务 ..创建另一个流,例如:- localhost:8088/consumeTest" exchange-pattern="request- response"> ....
    • 现在这是一个创建您喜欢使用的 web 服务的示例。如果您已经拥有该 web 服务,则不需要创建它.. 只需将 web 服务路径指向出站端点地址在您的 getversion 流程中...例如,如果您的外部 Web 服务 wsdl 位于 localhost:8086/webapi?wsdl,则只需将 localhost:8086/webapi 放入 http:outbound-endpoint 地址
    【解决方案2】:

    编辑后:

    更改为您的流程:

    <flow name="getVersion" doc:name="getVersion">
       <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>
    
    
    <cxf:jaxws-client operation="getVersion" serviceClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
    </cxf:jaxws-client>
    
    <http:outbound-endpoint exchange-pattern="request-response"  address="http://localhost:8088/consumeTest" doc:name="HTTP" method="POST"/>
    
    </flow>
    
    <flow name="consumeTest" doc:name="consumeTest">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="consumeTest" doc:name="HTTP"/>
        <logger doc:name="getVersion" message="Test AFTER" level="ERROR"/>
    </flow>
    

    答案是

    没有这样的操作:getVersion。无法通过端点路由事件: org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效负载是 类型:ContentLengthInputStream

    当我使用 clientClass 而不是 serviceClass 时:

    参数数量错误。无法通过端点路由事件: org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效负载是 类型:ContentLengthInputStream

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-14
      • 2012-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多