使用策略集构建符合 WS-security 安全规范的 JAX-WS Web Service 客户端

WAS6.1下WebService客户端构建
本文介绍如何在WebSphere Application Server 6.1环境下构建不依赖于任何应用服务器或Web容器的WebService客户端。文章详细解释了利用WSDL描述语言获取WebService接口信息的方法,并给出具体的WSDL示例。

术语说明

  • WAS6.1 本文特指安装了 Web Service Feature Pack 的 WebSphere Application Server 6.1;
  • 客户端本文特指不依赖任何应用服务器或 Web 容器的 Web Service 消费者,运行在 J2SE 单机环境中




回页首


WSDL

Web Service 客户端通过服务端的 Web 服务描述语言(WSDL)来获取 Web Service 提供者的接口信息,并且使用这个描述语言来构建客户端的文件。本文使用了如下的 WSDL 来描述服务器端的接口。


清单 1. WSDL
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/Echo/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="Echo" targetNamespace="http://www.example.org/Echo/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/Echo/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="requestEcho">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="req" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="echoHello">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="resp" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="echoRequestMsg">
<wsdl:part element="tns:requestEcho" name="parameters"/>
</wsdl:message>
<wsdl:message name="echoHello">
<wsdl:part element="tns:echoHello" name="parameters"/>
</wsdl:message>
<wsdl:portType name="Echo">
<wsdl:operation name="requestEcho">
<wsdl:input message="tns:echoRequestMsg"/>
<wsdl:output message="tns:echoHello"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EchoSOAP" type="tns:Echo">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="requestEcho">
<soap:operation soapAction="http://www.example.org/Echo/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Echo">
<wsdl:port binding="tns:EchoSOAP" name="EchoSOAP">
<soap:address location="http://localhost:9095/EchoWeb/Echo"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

此服务描述语言描述了服务器端提供了一个回声的 Web Service,它有一个字符串格式的输入参数,返回值也是一个字符串格式的参数。Web Service 的服务地址为 http://localhost:9095/EchoWeb/Echo。





回页首


构建过程





本文转自IBM Developerworks中国

      请点击此处查看全文


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值