1 Reply Latest reply on Dec 14, 2004 7:38 PM by thomas.diesler

    saaj namespace issue

    p_nevilleuk

      Hi,
      I am trying to using saaj to create ebXML soap message. I have two problems:
      1) I cannot change the prefix of the Envelope, Header etc. I would like SOAP instead of soapenv.
      2) More importantly, it repeats the namespace uri on each element, which is not necessary as it is declared in a parent element.

      Example soap message from code:
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmls
      oap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
      http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP="http://schemas.xmlsoap.or
      g/soap/envelope" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema
      /mgs-header-2_0.xsd">
      <soapenv:Header>
      <eb:MessageHeader xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/sch
      ema/mgs-header-2_0.xsd">
      <eb:From xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/mgs-
      header-2_0.xsd">
      <eb:PartyId xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/
      mgs-header-2_0.xsd"/>
      </eb:From>
      </eb:MessageHeader>
      </soapenv:Header>
      <soapenv:Body/>

      I would like:
      <SOAP:Envelope xmlns:SOAP="http://schemas.xmls
      oap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
      http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP="http://schemas.xmlsoap.or
      g/soap/envelope" xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema
      /mgs-header-2_0.xsd">
      <SOAP:Header>
      <eb:MessageHeader>
      <eb:From>
      <eb:PartyId/>
      </eb:From>
      </eb:MessageHeader>
      </SOAP:Header>
      <SOAP:Body/>


      Following is my code:
      SOAPConnectionFactory connFactory = SOAPConnectionFactory.newInstance();
      SOAPConnection connection = connFactory.createConnection();
      SOAPMessage message = MessageFactory.newInstance().createMessage();
      SOAPPart soapPart = message.getSOAPPart();


      SOAPEnvelope envelope = soapPart.getEnvelope();


      envelope.setPrefix("SOAP");
      envelope.addNamespaceDeclaration("SOAP", "http://schemas.xmlsoap.org/soap/envelope");
      envelope.addNamespaceDeclaration("eb", "http://www.oasis-open.org/committees/ebxml-msg/schema/mgs-header-2_0.xsd");

      SOAPFactory soapFactory = SOAPFactory.newInstance();
      Name messageHeader = soapFactory.createName("MessageHeader","eb","http://www.oasis-open.org/committe es/ebxml-msg/schema/mgs-header-2_0.xsd");


      SOAPHeader header = message.getSOAPHeader();
      SOAPHeaderElement headerElement = header.addHeaderElement(messageHeader);

      SOAPElement from = headerElement.addChildElement("From", "eb");
      from.addChildElement("PartyId", "eb");
      SOAPElement to = headerElement.addChildElement("To", "eb");
      to.addChildElement("PartyId", "eb");


      Any ideas?

      Many thanks for anyone able to help with this.

        • 1. Re: saaj namespace issue
          thomas.diesler

          Hi,

          not necessary is different from invalid. If the current Axis based implementation does not produce invalid messages, we probably won't fix it because there is too little to gain for too much efford.

          The new JBossWS implemenation has a shared NamespaceRegistry in the SerializationContext which should prevent this issue in future.