Skip to main content

JAX-RPC2: Accessing a returneed SOAP header

4 replies [Last post]
tim_walls
Offline
Joined: 2004-07-05

Hi all,

Using JAX-RPC2 as a web service client, is there a way to access the SOAP header object returned by a remote service call?

I'm using in the wscompile config, which is correctly generating code which allows me to pass the header object in method calls etc. It's not clear how I should access the SOAP header which the server is returning with its response, however!

I was thinking of trying to stick something in the handler chain which could access the SOAP envelope & header in the response directly, but this seems a little brute-force; is there a "correct" way of doing this?!

Thanks in advance,
Tim.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jitu
Offline
Joined: 2003-06-14

Since you are using , you should see both request&response headers(that are in WSDL) in SEI signatures. If you have questions, let us know with more info(like WSDL, and generated SEI)

tim_walls
Offline
Joined: 2004-07-05

Jitu,

Is there an address I can email the WSDL file/URL to you on? The service is a commercial offering and although the WSDL can be obtained publicly by anyone who knows the URL, I'm not comfortable with releasing it publicly myself without prior permission :-).

In the meantime, the generated interface looks like this (I've changed the URL/package but that's all:)

[b]
// This class was generated by the JAXRPC SI, do not edit.
// Contents subject to change without notice.
// JAX-RPC Standard Implementation (2.0, build EA3)
// Generated source version: 2.0

package com.anexample.services;

@javax.jws.WebService(
name="LoginSoap",
serviceName="Login_Service",
targetNamespace="http://services.anexample.com"
)
@javax.jws.soap.SOAPBinding(
style=javax.jws.soap.SOAPBinding.Style.DOCUMENT,
use=javax.jws.soap.SOAPBinding.Use.LITERAL,
parameterStyle=javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED)
public interface LoginSoap extends java.rmi.Remote {
@javax.jws.WebMethod(operationName="ServiceLogin", action="http://services.anexample.com/ServiceLogin")
@com.sun.ws.WebWrapper(requestWrapper="com.anexample.services.ServiceLogin",
responseWrapper="com.anexample.services.ServiceLoginResponse")
public void serviceLogin(
@javax.jws.WebParam(name="aeHeader", header=true, mode=javax.jws.WebParam.Mode.INOUT)

javax.xml.rpc.holders.GenericHolder aeHeader) throws
java.rmi.RemoteException;

}[/b]

The header parameter is correctly specified for the input, but I don't see any way of accessing it in the response. I guess it's possible that there is an error in the WSDL; if you're indicating that returned headers [i]should[/i] be accessible, I'll take a look at the WSDL.

What should the interface look like to obtain the SOAP header from a response; if I know what should be being generated I might be able to work out how to fix the WSDL more easily :-).

Regards,
Tim.

jitu
Offline
Joined: 2003-06-14

aeHeader is GenericHolder. You use this for both request and response headers. Once the invocation ends, client can use aeHeader.value for response header.

aeHeader.value = // request header
serviceLogin(aeHeader)
aeHeader.value // response header

tim_walls
Offline
Joined: 2004-07-05

D'oh! That does indeed work, my bad...

Thanks very much for the help,
Tim.