编写使 WSIF 服务能够访问 JMS 目标处提供的服务的 WSDL 扩展
通过使用本机 Java™ 消息服务 (JMS) 提供程序,Web Services Invocation Framework (WSIF) 客户机可以将 JMS 目标处提供的服务视作 Web Service。使用此信息和相关联的代码段来帮助您编写 Web Service 描述语言 (WSDL) 扩展。
开始之前
关于此任务
JMS 的 WSDL 扩展用名称空间前缀 jms 识别。例如,<jms:binding>。
支持的操作是单向操作(send 用于 JMS 点到点消息传递,或者 publish 用于 JMS 发布和预订消息传递)或“请求/响应”操作(send 和 receive 用于 JMS 点到点消息传递)。因此,WSDL 操作仅指定输入消息,或输入和输出消息。
描述带有本机 JMS 绑定的消息接口的操作没有故障消息。不假设消息模式或消息属性的语义,因此输出和故障消息之间没有区别。
使用以下过程和相关联的代码段来帮助您编写 Web Service 描述语言 (WSDL) 扩展,以允许 WSIF 服务访问 JMS 目标处提供的底层服务。
过程
示例 1:JMS 文本消息
JMS 文本消息包含 java.lang.String。在此示例中,WSDL 消息只包含表示整个消息体的一个部分:
<wsdl:definitions ... >
<!-- simple or complex types for input and output message -->
<wsdl:types> ... </wsdl:types>
<wsdl:message name="JmsOperationRequest"> ... </wsdl:message>
<wsdl:message name="JmsOperationResponse"> ... </wsdl:message>
<wsdl:portType name="JmsPortType">
<wsdl:operation name="JmsOperation">
<wsdl:input name="Request"
message="tns:JmsOperationRequest"/>
<wsdl:output name="Response"
message="tns:JmsOperationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="JmsBinding" type="JmsPortType">
<jms:binding type="TextMessage" />
<format:typemapping style="Java" encoding="Java">
<format:typemap name="xsd:String" formatType="String" />
</format:typemapping>
<wsdl:operation name="JmsOperation">
<wsdl:input message="JmsOperationRequest">
<jms:input parts="requestMessageBody" />
</wsdl:input>
<wsdl:output message="JmsOperationResponse">
<jms:output parts="responseMessageBody" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="JmsService">
<wsdl:port name="JmsPort" binding="JmsBinding">
<jms:address destinationStyle="queue"
jndiConnectionFactoryName="myQCF"
jndiDestinationName="myDestination"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
作为先前 JMS 消息示例的扩展,以下示例 WSDL 描述了“请求/响应”操作,在此操作中,请求和响应消息的特定 JMS 属性值是为请求消息设置的,并且从响应消息中接收。
根据输入消息中的值设置请求消息中的 JMS 属性。同样,响应消息的所选 JMS 属性会复制到输出消息的相应值。映射的方向分别由输入或输出部分中出现的 <jms:property> 标记确定。
<wsdl:definitions ... >
<!-- simple or complex types for input and output message -->
<wsdl:types> ... </wsdl:types>
<wsdl:message name="JmsOperationRequest">
<wsdl:part name="myInt" type="xsd:int"/>
...
</wsdl:message>
<wsdl:message name="JmsOperationResponse">
<wsdl:part name="myString" type="xsd:String"/>
...
</wsdl:message>
<wsdl:portType name="JmsPortType">
<wsdl:operation name="JmsOperation">
<wsdl:input name="Request"
message="tns:JmsOperationRequest"/>
<wsdl:output name="Response"
message="tns:JmsOperationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="JmsBinding" type="JmsPortType">
<!-- the JMS message type might be any of the preceding types -->
<jms:binding type="..." />
<format:typemapping style="Java" encoding="Java">
<format:typemap name="xsd:int" formatType="int" />
...
</format:typemapping>
<wsdl:operation name="JmsOperation">
<wsdl:input message="JmsOperationRequest">
<jms:property message="tns:JmsOperationRequest" parts="myInt" />
<jms:propertyValue name="myLiteralString"
type="xsd:string" value="Hello World" />
...
</wsdl:input>
<wsdl:output message="JmsOperationResponse">
<jms:property message="tns:JmsOperationResponse" parts="myString" />
...
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="JmsService">
<wsdl:port name="JmsPort" binding="JmsBinding">
<jms:address destinationStyle="queue"
jndiConnectionFactoryName="myQCF"
jndiDestinationName="myDestination"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>