raz*_*nha 13 .net java axis soap web-services
我正在尝试使用Axis使用.NET 2.0 Web服务.我使用Eclipse WST插件生成了Web服务客户端,到目前为止似乎还可以.
这是预期的SOAP标头:
<soap:Header>
<Authentication xmlns="http://mc1.com.br/">
<User>string</User>
<Password>string</Password>
</Authentication>
</soap:Header>
Run Code Online (Sandbox Code Playgroud)
我没有找到任何有关如何从Axis客户端配置此标头的文档.当我使用Visual Studio C#Express 2008生成客户端时,它生成一个以Authentication两个String属性(User和Password)命名的类,并且所有客户端方法都接收此类的对象作为第一个参数,但Axis WS客户端不会发生这种情况.
如何在客户端调用中设置此标头?
mar*_*its 30
也许你可以使用org.apache.axis.client.Stub.setHeader方法?像这样的东西:
MyServiceLocator wsLocator = new MyServiceLocator();
MyServiceSoap ws = wsLocator.getMyServiceSoap(new URL("http://localhost/MyService.asmx"));
//add SOAP header for authentication
SOAPHeaderElement authentication = new SOAPHeaderElement("http://mc1.com.br/","Authentication");
SOAPHeaderElement user = new SOAPHeaderElement("http://mc1.com.br/","User", "string");
SOAPHeaderElement password = new SOAPHeaderElement("http://mc1.com.br/","Password", "string");
authentication.addChild(user);
authentication.addChild(password);
((Stub)ws).setHeader(authentication);
//now you can use ws to invoke web services...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
41183 次 |
| 最近记录: |