简体   繁体   English

如何在Java中发送SOAP请求标头?

[英]How to send SOAP request header in Java?

I have a WSDL file (the web-service has written by .NET) and i can generate the java web-service client proxy classes and codes in IntelliJ IDEA 7.0.4 by its tool. 我有一个WSDL文件(Web服务由.NET编写),我可以通过其工具在IntelliJ IDEA 7.0.4中生成java web服务客户端代理类和代码。 the web-service has a soap request header , but i can't see any property or method in auto generated Java proxy classes and codes to set the request header. Web服务有一个soap请求标头,但我看不到自动生成的Java代理类和代码中的任何属性或方法来设置请求标头。 (but when i use Visual Studio 2008 to generate the proxy classes for C#, an object is created in web-service proxy class as the header so i can set fill it simply) (但是当我使用Visual Studio 2008为C#生成代理类时,会在Web服务代理类中创建一个对象作为标题,因此我可以设置简单填充它)

what should i do in Java? 我该怎么做Java?

I'm not sure what IntelliJ uses to generate proxy classes. 我不确定IntelliJ使用什么来生成代理类。 AXIS maybe? AXIS可能吗?

I do know that if you want to do this with CXF, when you are defining your client, the best way is to create a class that implement SoapInterceptor and then set it as an outbound Interceptor. 知道 ,如果你想与CXF要做到这一点,当你定义你的客户,最好的办法是创建一个实现SoapInterceptor然后将其设置为出拦截器的类。

public void handleMessage(SoapMessage message) throws Fault {
           message.getHeaders().add(QName.valueOf("foo"), "bar");
   }

Ultimately though, it's going to be hard for you to figure out the right way to handle this if you don't know the library your IDE is using. 但最终,如果您不知道IDE正在使用的库,那么您很难找到正确的方法来处理这个问题。

All the classes for a complete web service client can be created by wsimport tool included in jdk. 可以通过jdk中包含的wsimport工具创建完整Web服务客户端的所有类。

http://download.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html http://download.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

You only need to specify the wsdl address. 您只需要指定wsdl地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM