在Web Services中管理Sessions
http://tech.ddvip.com 2006年11月25日 社区交流
本文详细介绍在Web Services中管理Sessions
java -cp [classpath to axis bits here] /
org.apache.axis.client.AdminClient /
-lhttp://localhost/myservice/AxisServlet
deploy.wsdd现在服务器就可以运行了,在使用该handler时服务器无需处理任何事情;而headers能够自动被添加进去,就像这样:
<soapenv:Header>
<ns1:sessionID soapenv:actor=""
soapenv:mustUnderstand="0"
xsi:type="xsd:long"
xmlns:ns1=
"http://xml.apache.org/axis/
session">
-1919645576528915916
</ns1:sessionID>
</soapenv:Header>要使用这个header,Web service客户端必须能够读取它并了解其语法;而Axis客户端可以解决这个问题。
要创建一个使用这个简单session的Axis客户端,你需要配置Axis客户端框架来使用该handler。过程同服务器端很相似,但不是部署到服务器,而是在本地创建config文件。你可以通过运行org.apache.axis.utils.Admin来实现这一点。运行以下代码:org.apache.axis.utils.Admin client deploy.wsdd
这样就创建了一个client-config.wsdd文件,它同样也包含handler代码。
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns=
"http://xml.apache.org/axis/wsdd/"
xmlns:java= "http://xml.apache.org/axis/
wsdd/providers/java">
<globalConfiguration>
<parameter name="adminPassword"
value="admin"/>
<parameter name="attachments.implementation"
value=
"org.apache.axis.attachments.
AttachmentsImpl"/>
<parameter name=
"sendMultiRefs" value="true"/>
<parameter name="sendXsiTypes" value=
"true"/>
<parameter name=
"sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements"
value="true"/>
<requestFlow>
<handler type=
"java:org.apache.axis.handlers.
SimpleSessionHandler"/>
</requestFlow>
<responseFlow>
<handler type=
"java:org.apache.axis.handlers.
SimpleSessionHandler"/>
</responseFlow>
</globalConfiguration>
<handler name="session" type=
"java:org.apache.axis.handlers.
SimpleSessionHandler"/>
<service name="Sessions" provider=
"java:RPC" style="wrapped" use="literal">
<requestFlow>
<handler type="session"/>
</requestFlow>
<responseFlow>
<handler type="session"/>
</responseFlow>
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value=
"kevinj.UseSessions"/>
<namespace>urn:kevinj:Sessions</namespace>
</service>
<transport name="java" pivot=
"java:org.apache.axis.transport.
java.JavaSender"/>
<transport name="http" pivot=
"java:org.apache.axis.transport.
http.HTTPSender"/>
<transport name="local" pivot=
"java:org.apache.axis.transport.
local.LocalSender"/>
</deployment>为了使客户端能够利用这个handler,你必须将client-config.wsdd文件添加到客户端的classpath中。然后由Axis框架代表客户端来读取并响应这些headers。同样,客户端代码无需处理任何事情便可以使用它了。
责编:豆豆技术应用
正在加载评论...