2 Replies Latest reply: May 30, 2012 4:17 AM by 895676 RSS

    How to override the default SOAP envelope prefix?

    ntsang
      I have a Web service as an external reference. In run-time WebLogic generates SOAP messages with a default prefix <env:Envelope xmlns:env=http://schemas.xmlsoap.org/soap/envelope/”…>. Normally this is fine. However the Web service required a prefix as <soapenv:…>. How can I have WebLogic generate soap envelope prefix as soapenv instead env?
        • 1. Re: How to override the default SOAP envelope prefix?
          Patrick Taylor
          However the Web service required a prefix as <soapenv:…>. How can I have WebLogic generate soap envelope prefix as soapenv instead env?
          This should not be the case. As long as the env is referring to the correct namespace - xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" the receiving webservice should be able to process the request.

          If you are not able to successfully invoke the webservice, then there is some other issue and not an issue with the prefix of env.

          Thanks,
          Patrick
          • 2. Re: How to override the default SOAP envelope prefix?
            895676
            hello!

            It's possible. You must implement handler and change envelope and body prefix. Here is example:

            public class WsHandler implements SOAPHandler<SOAPMessageContext> {

            ....
            public boolean handleMessage(SOAPMessageContext context) {
            Boolean outboundProperty =
            (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                      
            if (outboundProperty.booleanValue()) {

            try {
                 
            SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();

            envelope.setPrefix("soapenv");
            envelope.removeNamespaceDeclaration("env"); //remove old prefix
            envelope.getBody().setPrefix("soapenv");

            context.getMessage().saveChanges();

            } catch (Exception e) {
                 throw new ProtocolException(e);
            }

            }

            }

            }