2017-08-17 335 views
0

我现在用IBM集成总线。当我不声明它给默认NS1我响应体任何命名空间,这样的:IBM JAVA节点更改默认命名空间前缀(NS1)

<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节点代码:

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); 

我要改变 “NS1:” 为 “e:”。我如何做到这一点?

回答

0

最后,我找到解决办法。您可以添加以下代码的前缀:

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