Results 1 to 4 of 4
- 08-05-2010, 11:48 PM #1Member
- Join Date
- Aug 2010
- Rep Power
Adding WS Addressing to SOAP header - ACK!
I am using Axis2 to generate client code and a unit test from a partners WSDL. In the resulting test, the SOAP xml is being generated just fine, except that there is no header being generated.
They're using WS-Addressing, and require their header to look something like:
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> <wsa:Action>http://endpoint1URL </wsa:Action> <wsa:To>http://endpoint2URL </wsa:To> </soapenv:Header>
It seems like I should do something like this:
Options options = new Options(); options.setAction("enpoint1URL"); options.setTo(new EndpointReference("endpoint2URL")); stub._getServiceClient().setOptions(options);
Can someone help? How do I get that info into the header of my SOAP envelope?
- 08-06-2010, 12:59 AM #2
I think this is the ws-addressing module, that comes with axis2 distribution, but might need to be engaged in the server and the client by specifying the <module ref="addressing"/> in the axis2.xml.
See: Axis2/Java - Axis2 Advanced User's Guide
WS-Addressing support for Axis2 is implemented by the addressing module. To enable addressing, you need to engage the addressing module in both server and client sides.
1. To enable addressing at the server side, you need to copy the addressing.mar file to the modules directory of the server's axis2 repository. To engage the module, add a <module ref="addressing"/> to axis2.xml. The Addressing module can be engaged only at global level.
2. To enable addressing at the client side, you should add it to the repository and provide the repository as an argument to the ServiceClient or generated stub or have it in your classpath.
3. To engage the addressing module, you should either add <module ref="addressing"/> to the axis2.xml file at the client side or call
- 08-06-2010, 06:06 AM #3Member
- Join Date
- Aug 2010
- Rep Power
Thanks for the reply. That's just what I've done. Makes me wonder if my axis2.xml file is in the right place. I used axis2 wsdl2java from the command line (separate install) to generate the stub. Jarred up the class files with the generated build.xml and then included the jar in my maven repo. Then I use the classes in Eclipse. With all of those shenanigans, I'm not sure where the axis2.xml file should go. I also read about addressing.mar file, which should be with the axis2.xml file. Anywhere in my classpath, I guess?
- 08-06-2010, 11:16 PM #4
I would really love it if there was a way to stuff the axis2.xml into the classpath, then I would just shove it into the top level package inside my client jar file. But so far I have found axis2 clients really like to have
- the axis2.xml as a FILE SYSTEM path
- also a path to the crazy location of all these modules (*.mar) files, like the ws-addressing module.
For example, I boot up my axis2 client like this :
String endpoint = "http://127.0.0.1:myapp/services/MyService"; String pathToRepository = "./config/axis2"; // this contains nested folder "modules", which then contains the addressing.mar file String pathToClientConfig = "./config/axis2.xml"; // define a configuration context that knows where to find the axis2.xml // and the folder that contains the modules/ folder, that contains the .mar files modules we want to engage. ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(pathToRepository,pathToClientConfig); . // create instance of your service client using this context MyServiceStub stub = new MyServiceStub(ctx,endPoint); // now use your service client
- By email@example.com in forum Advanced JavaReplies: 1Last Post: 10-18-2010, 05:03 PM
- By Quirl in forum New To JavaReplies: 2Last Post: 07-28-2010, 10:19 PM
- By kevinnrobert in forum NetworkingReplies: 2Last Post: 04-02-2010, 06:06 PM
- By selva.bics in forum New To JavaReplies: 0Last Post: 11-26-2009, 03:26 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 11-26-2007, 02:30 PM