Eclipse Mule:如何使用来自远程客户端的服务

Eclipse Mule:如何使用来自远程客户端的服务,eclipse,web-services,wsdl,mule,endpoint,Eclipse,Web Services,Wsdl,Mule,Endpoint,我一直在学习这个教程,它非常适合使用WSDL中的wb服务。 我一直在尝试通过使用CXF在Eclipse中生成客户机web服务并在Mule中发布web服务来实现类似的方法。我的问题是:如果我将客户机和mule应用程序配置为具有相同的端点(例如:localhost:8082/ipsoap/test),那么如何让web服务以与本教程相同的方式工作。 这意味着,如果我测试从客户机(在eclipse中)向mule发送请求,我应该从mule收到正确的响应。提前感谢您抽出时间 简言之: 1-我在本教程的以下链

我一直在学习这个教程,它非常适合使用WSDL中的wb服务。 我一直在尝试通过使用CXF在Eclipse中生成客户机web服务并在Mule中发布web服务来实现类似的方法。我的问题是:如果我将客户机和mule应用程序配置为具有相同的端点(例如:localhost:8082/ipsoap/test),那么如何让web服务以与本教程相同的方式工作。 这意味着,如果我测试从客户机(在eclipse中)向mule发送请求,我应该从mule收到正确的响应。提前感谢您抽出时间

简言之:

1-我在本教程的以下链接中使用wsdl在eclipse中生成了一个客户端应用程序:

2-作为Mule的开始,我添加了一个http连接器和一个记录器,并将eclipse中的端点路径更改为我在Mule上的http连接器上设置的路径。因此,当我在Eclipse中从客户机向Mule发送请求时,我可以看到有一个有效负载

3-我需要一个应用程序,即eclipse中的客户端应用程序,使用Mule中发布的服务。现在我认为这是通过使用CXF组件实现的,但我仍然无法使它工作。事实上,我想知道这是否是使用Mule的一种有效方法,因为我找不到任何关于我要实现的目标的教程

下面是我测试它的方法:

我使用了在Mule中使用的相同端点,并收到以下日志:

> INFO  2014-07-07 13:19:46,124
> [[soapservice].connector.http.mule.default.receiver.02]
> org.mule.api.processor.LoggerMessageProcessor: message transformation
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:q0="http://ws.cdyne.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
> <soapenv:Body>
>     <q0:ResolveIP>
>       <q0:ipAddress>173.194.36.39</q0:ipAddress>
>       <q0:licenseKey/>
>     </q0:ResolveIP>   </soapenv:Body> </soapenv:Envelope>
> 
> ERROR 2014-07-07 13:19:46,134
> [[soapservice].connector.http.mule.default.receiver.02]
> org.mule.exception.DefaultMessagingExceptionStrategy: 
> ******************************************************************************** Message               : wrong number of arguments. Failed to route
> event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor.
> Message payload is of type: String Code                  :
> MULE_ERROR--2
> -------------------------------------------------------------------------------- Exception stack is:
> 1. wrong number of arguments (java.lang.IllegalArgumentException)   sun.reflect.NativeMethodAccessorImpl:-2 (null)
> 2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
> type: String (org.mule.api.transport.DispatchException)  
> org.mule.module.cxf.CxfOutboundMessageProcessor:150
> (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
> -------------------------------------------------------------------------------- Root Exception stack trace: java.lang.IllegalArgumentException: wrong
> number of arguments   at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>     + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
>信息2014-07-07 13:19:46124
>[[soapservice].connector.http.mule.default.receiver.02]
>org.mule.api.processor.LoggerMessageProcessor:消息转换
>xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/"
>xmlns:q0=”http://ws.cdyne.com/"
>xmlns:xsd=”http://www.w3.org/2001/XMLSchema"
>xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance">  
> 
>     
>       173.194.36.39
>       
>         
> 
>错误2014-07-07 13:19:46134
>[[soapservice].connector.http.mule.default.receiver.02]
>org.mule.exception.defaultMessaginExceptionStrategy:
>******************************************************************************************************************************************消息:参数数目错误。路由失败
>通过端点的事件:org.mule.module.cxf.CxfOutboundMessageProcessor。
>消息负载的类型为:字符串代码:
>MULE_错误--2
>--------------------------------------------------------------异常堆栈是:
> 1. 参数数目错误(java.lang.IllegalArgumentException)sun.reflect.NativeMethodAccessorImpl:-2(null)
> 2. 参数数量错误。无法通过终结点org.mule.module.cxf.CxfOutboundMessageProcessor路由事件。消息有效负载是
>类型:字符串(org.mule.api.transport.DispatchException)
>org.mule.module.cxf.CxfOutboundMessageProcessor:150
> (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
>--------------------------------------------------------------根异常堆栈跟踪:java.lang.IllegalArgumentException:错误
>上的参数数
>sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于
>位于的sun.reflect.NativeMethodAccessorImpl.invoke(未知源)
>sun.reflect.DelegatingMethodAccessorImpl.invoke(未知源)
>+3更多(为所有内容设置调试级别日志或“-Dmule.verbose.exceptions=true”)
正如您所看到的,可以看到soap请求,但它不是在CXF组件级别使用的。这是我的mule代码:

<flow name="SoapService" doc:name="SoapService">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="test/cap.asmx" doc:name="HTTP"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <logger message="message transformation #[message.payload]" level="INFO" doc:name="Logger"/>
        <flow-ref name="RequestResponse" doc:name="Flow Reference"/>
        <logger level="INFO" doc:name="Logger" message="after posting #[message.payload]"/>
        <mulexml:object-to-xml-transformer doc:name="Object to XML"/>
    </flow>
    <flow name="RequestResponse" doc:name="RequestResponse">
        <cxf:jaxws-client operation="ResolveIP" clientClass="pck.IP2Geo" port="IP2GeoSoap" wsdlLocation="file:/C:/Users/12204-hajjam1/workspace/ipgo/src/ipgeo.wsdl" doc:name="soap 2"/>
        <logger message="before posting #[message.payload]" level="INFO" doc:name="Logger"/>
        <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:10387/ip2geo/ip2geo.asmx" doc:name="HTTP"/>
    </flow>

另外,如果我在cxf组件之前添加一个带有ip#[{'173.194.36.39',''}](第二个参数可以为空)的set有效负载,它将返回一个空元素。然而,答案应该是这样的:

<pck.IPInformation>
<city>Mountain View</city>
<stateProvince>CA</stateProvince>
<country>United States</country>
<organization/>
<latitude>37.4192</latitude>
<longitude>-122.0574</longitude>
<areaCode>0</areaCode>
<timeZone/>
<hasDaylightSavings>false</hasDaylightSavings>
<certainty>90</certainty>
<regionName/>
<countryCode>US</countryCode>
</pck.IPInformation> 

山景
加利福尼亚州
美国
37.4192
-122.0574
0
假的
90
美国
因此,我的问题是响应的消耗和检索。
很抱歉这么长时间,但我一直在努力解决这个问题,还没有在网上找到解决方案。提前感谢。

您应该创建一个message类的实例,该实例是从WSDL为
ResolveIP
方法生成的,并将其用作
cxf:jaxws-client
元素之前的消息负载。

很抱歉,我无法理解您试图实现的目标。你可以扩展/重新表述你的问题吗?谢谢你的快速回答,我已经编辑了我的问题。我希望这样可以,否则我可以说得更清楚。任何意见都将不胜感激。谢谢。事实上,我试着按照建议设置有效负载,它工作正常。然而,我通过删除cxf客户机并简单地留下一个带有WSDL位置地址的HTTP出站来找到问题,现在它返回正确的响应。因此,问题在于有两个客户机,一个在eclipse中,另一个在mule中。谢谢你的回答!