xmlxsdxml-namespacesibm-integration-bus

IBM JAVA node change default namespace prefix (NS1)


I 'am using IBM integration bus.When I don't declare any namespace it gives default NS1 to my response body, like that:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <NS1:AvansEditResponse xmlns:NS1="http://Elma.sample.az">
     <Result>     
        <Error>
           <Exists>true</Exists>
           <ECode>E005</ECode>
           <EMessage>Avans editing error!</EMessage>
        </Error>
     </Result>
  </NS1:AvansEditResponse>

JAVA Node codes:

    MbOutputTerminal out = getOutputTerminal("out");
    MbOutputTerminal alt = getOutputTerminal("alternate");

    MbMessage inMessage = inAssembly.getMessage();
    MbMessage outMessage = new MbMessage();

    MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
    MbElement outputBody = outAssembly.getMessage().getRootElement().createElementAsLastChild(MbXMLNSC.PARSER_NAME);

    OracleCallableStatement ostmt = null;

    //creating response element 
    MbElement responseMethod = outputBody.createElementAsLastChild(MbElement.TYPE_NAME, "AvansAddResponse", null);

    responseMethod.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "e" ,Constants.ELMA_NAMESPACE);

    MbElement responseResult = responseMethod.createElementAsLastChild(MbElement.TYPE_NAME, "Result", null);

I want to change "NS1:" to "e:". How I can do it ?


Solution

  • Finally , I find solution . You can add prefix with following codes :

        MbElement vasDecl = response.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "e", Constants.ELMA_NAMESPACE); 
        vasDecl.setNamespace("xmlns"); 
        response.setNamespace(Constants.ELMA_NAMESPACE);