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

Reply via email to