亲爱的大家,在新年的第一天。
我的目标是:
我有两个axis2 ws2服务(ws1,ws2)部署在wso2as中。客户机必须通过wso2esb给出参数给ws1,而返回的值必须作为将最终值返回给客户端的参数给ws2。因此,客户端所做的就是将参数提供给ws1并接收来自ws2的最终响应。
问题:
如何一步一步地实现ws1和ws2之间的通信(我认为是通过代理)?因为我试过很多家教,没有人是为了我的详细原因,我真的是ESBs的乞丐。
非常感谢。
发布于 2013-01-04 05:33:33
是。你可以一步到位。我以前曾在一个项目中这样做过:下面是您可以遵循的步骤:
1. ws1 and ws2 are both have "endpoints" defined in the ESB.
2. In the ws1 proxy, define a target inSequence to point to a "sequence"
for example "ws1InSequence"
3. In the "ws1InSequence", you can use <filter> to make sure the value is exists.
Then you can <send> to the ws1 <endpoint> with "receive" attribute point to
a sequence for example "ws1ResultSequence"
4. In the ws1ResultSequence, you can again use the <filter> to make sure
it has the parameter/value you need. Then you can use param/value to format a request message.
<payloadFactory>
<format>
<ns1: ws2Operation
xmlns:ns1="ws2Namespace">
<element1 xmlns="">$1</element1>
<!-- Note $1 will have the //paramName value from the ws1 Result message -->
<element2 xmlns="">$2</element2>
<!-- Note $2 will have the //paramName2 value from the ws1 Result message -->
</format>
<args>
<arg expression="//paramName" />
<arg expression="//paramName2" />
</args>
</payloadFactory>
5. Still in ws1ResultSequence, after you create the request message,
you <send> it to the ws2 proxy. Then in the ws2 proxy, in the <outSequence>
you can juse use <send/> to send the response to the client.注意,您可能需要包括异常(FaultSequence)处理。
WSO2ESB使用Apache进行配置。您可以在它们的doc:http://synapse.apache.org/userguide/config.html中找到大多数语法和示例用法
更新:您可以使用此示例。注意,这可能不是您需要的完整代码,您可能需要添加异常处理。
<sequence xmlns="http://ws.apache.org/ns/synapse" name="ws1ResultSequence"
trace="enable" onError="ws1ResultSequenceErrorHandler">
<log level="custom">
<property name="sequence" value="INVOCATION START: ws1ResultSequence" />
</log>
<!-- record the original message for future reference -->
<enrich>
<source clone="true" type="envelope" />
<target action="replace" type="property" property="ORIGINAL" />
</enrich>
<!-- Check if the ws1 result message has the value -->
<property
xmlns:ns1="ws1Namespace"
name="valueExists" expression="//ns1:element1" />
<!--Note here, element1 is the element name which has the value: output1 -->
<filter xpath="fn:boolean( get-property('valueExists') )">
<then>
<!-- create the request message to invoke ws2 -->
<payloadFactory>
<format>
<ns1:ws2OperationName
xmlns:ns1="ws2Namespace">
<element2 xmlns="">$1</element2>
</ns1:ws2OperationName>
</format>
<args>
<arg expression="//ns1:element1" />
</args>
</payloadFactory>
<log level="custom">
<property name="inInvokeWS2" value="INVOCATION START: value from ws1 result exists" />
</log>
<send>
<endpoint key="ws2Sequence" />
</send>
<drop/>
</then>
</filter>
<!-- No result value found from the ws1 result message -->
<send>
<endpoint key="DoSomethingElseOrThrowError" />
</send>
发布于 2013-01-03 05:30:40
您需要做的是调用ws1,获取响应,从响应中提取值,然后创建要发送给ws2的有效负载并调用ws2。这次网络研讨会展示了如何执行类似的场景。
发布于 2013-01-04 17:15:25
我将尝试解释以下所有步骤:
WebServices
wsOne:
EndPoint (In wso2as): http://localhost:9765/services/wsOne
WSDL (In wso2as): http://localhost:9765/services/wsOne?wsdl
wsTwo:
EndPoint (In wso2as): http://localhost:9765/services/wsTwo
WSDL (In wso2as): http://localhost:9765/services/wsTwo?wsdl
序列
ServiceBus ->序列->定义的序列->添加序列。
ws1ResultSequence
我不知道必须包含什么,因为当我试图创建有效载荷时,我犯了错误。
ws1InSequence
<sequence xmlns="http://ws.apache.org/ns/synapse"><in>
<filter>
<then>
<send receive="ws1ResultSequence">
<endpoint>
<address uri="http://localhost:9765/services/wsOne"/>
</endpoint>
</send>
</then>
<else/>
</filter>
</in>
</sequence>ws2Sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="conf:/ws2Sequence">
<out>
<send/>
</out>
</sequence>代理
ws1Proxy
添加->代理服务->Custom代理->名称: ws1proxy,发布wsdl: No,Next ->定义InSequence-> -> from Registry-> ws1InSequence。
ws2Proxy
添加->代理服务->Custom代理->名称: ws2proxy,发布wsdl: No,Next ->定义InSequence-> -> from Registry-> ws2Sequence。
我的脚步对不对?我知道我犯了很多错误,因为这是我第一次与SOA、ESB、.客户端必须执行哪些操作才能启动链接并获得所需的结果(ws1Proxy)或其他结果?
非常感谢你抽出时间。
https://stackoverflow.com/questions/14131335
复制相似问题