Thanks everybody for suggestions. The one below actually worked. I was
able to send a message with "To" element required by spec which was
different from the endpoint reference used as address to send.

 

Victor

 

________________________________

From: Eran Chinthaka [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 05, 2008 12:36 AM
To: axis-user@ws.apache.org
Subject: Re: [AXIS2] - How to control "To" element in the SOAP header?

 

Hi Victor,

WS-Addressing specification implementation is a module within Axis2. If
you engage that, then it will put relevant headers in to SOAP messages.
So users are not expected to mess with those headers.

If you want to set two different values to wsa:To and transport endpoint
address, there is a well defined way to do that. 

options.setProperty(Constants.Configuration.TRANSPORT_URL,"http://SOAP/m
essage/should/go/here");

and use options.setTo() method to put the address you want to put into
wsa:To header. 

It should work.

HTH.
Chinthaka

On Wed, Jun 4, 2008 at 3:00 PM, Victor Solakhian
<[EMAIL PROTECTED]> wrote:

Hi Chinthaka,

 

Actually createSOAPEnvelope() method is mine. It creates an envelope
that has "To" element in the header according to specs of the Web
Servcies server. The Axis2 code that sends the message adds another "To"
header block using the value that was set in options.setTo() method.

 

The problem is that sometimes servers expect values in the "To" element
that differ from the value of the endpoint reference used to send
messages. I do not know if this is a bug in Axis2. I know that some
developers used Axis1 to successfully implement desired behavior.

 

Thanks

 

________________________________

From: Eran Chinthaka [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 04, 2008 5:41 PM
To: axis-user@ws.apache.org
Subject: Re: [AXIS2] - How to control "To" element in the SOAP header?

 

Hi Victor,

If createSOAPEnvelope() method adds wsa:To header, then it is a bug,
IMO. Please create a bug in JIRA and someone will look in to this (but
it might take some time for me to commit in to this :( )

Thanks,
Chinthaka

On Wed, Jun 4, 2008 at 10:37 AM, Victor Solakhian
<[EMAIL PROTECTED]> wrote:

I have code that creates a SOAP envelope and sends it using Axis2
ServiceCLient.

 

        EndpointReference targetEPR = 

        new EndpointReference("https://...";);

 

        String action = "...";        

        client = new ServiceClient(ctx, null);

        operationClient =
client.createClient(ServiceClient.ANON_OUT_IN_OP);

 

        MessageContext outMsgCtx = new MessageContext();

        Options options = outMsgCtx.getOptions();

        options.setTo(targetEPR);

 
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

        options.setProperty(HTTPConstants.CHUNKED, false);

        options.setAction(action);

        

        outMsgCtx.setEnvelope(createSOAPEnvelope(operation, payload));

        operationClient.addMessageContext(outMsgCtx);

        operationClient.execute(true);

 

Now the createSOAPEnvelope(operation, payload)) method creates an
envelope with a header  that includes:

 

      <soapenv:Header>

                        ...

                        <wsa:To

 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing";>

                                    urn:xxx.yyy.com.zzz

                        </wsa:To>

 

which is expected by the web services server, but Axis2 code adds
another To" element:

 

                        <wsa:To>

                                    https://...

                        </wsa:To>

 

to the header (using the endpoint reference set by
options.setTo(targetEPR)).

 

We need to set the targetEPR to  the options so that messages are sent
to the right place, but we need to have control on what is put in the
header.

 

Is there a way to avoid adding the targetEPR to the header?

 

Thanks,

 

Victor




-- 
With Mettha,
Eran Chinthaka

--------------------------------------------------------------------
Health is the greatest gift; contentment is the greatest wealth;
trusting is the best relationship; nirvana is the highest joy. -
Dhammapada 




-- 
With Mettha,
Eran Chinthaka

--------------------------------------------------------------------
Health is the greatest gift; contentment is the greatest wealth;
trusting is the best relationship; nirvana is the highest joy. -
Dhammapada 

Reply via email to