Results 1 to 4 of 4
  1. #1
    themdg is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default Adding WS Addressing to SOAP header - ACK!

    Hi, Everyone.

    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:

    Java Code:
    <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>
    I can not, for the love of mike, figure out how to get this wsa info into the header.

    It seems like I should do something like this:

    Java Code:
    Options options = new Options();
    options.setAction("enpoint1URL");
    options.setTo(new EndpointReference("endpoint2URL"));
    stub._getServiceClient().setOptions(options);
    The options get set...but the headers are always missing. It's only if I adding custom headers that I can get _any_ headers to show up.

    Can someone help? How do I get that info into the header of my SOAP envelope?

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    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

    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
    stub._getServiceClient().engageModule(moduleName)

  3. #3
    themdg is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default

    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?

  4. #4
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    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 :
    Java Code:
    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
    When I build web applications that in turn need to contain axis2 clients (and maybe even also be its own axis2 services), I create an initializer servlet that determines the real path from the servlet context. Thats the hard part for me that I haven't figured out, how to nicely make a launcher for the web services client that will detect the configuration folder path in a command line or stand alone application, without making some shell script or batch file to set up the current working folder before hand that is.

Similar Threads

  1. problem when generating MIME header of a SOAP packet using SAAJ
    By kumar.jyotish@gmail.com in forum Advanced Java
    Replies: 1
    Last Post: 10-18-2010, 05:03 PM
  2. Fixed Header
    By Quirl in forum New To Java
    Replies: 2
    Last Post: 07-28-2010, 10:19 PM
  3. ip addressing
    By kevinnrobert in forum Networking
    Replies: 2
    Last Post: 04-02-2010, 06:06 PM
  4. Header/Footer
    By selva.bics in forum New To Java
    Replies: 0
    Last Post: 11-26-2009, 02:26 PM
  5. Getting Header Info
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-26-2007, 01:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •