以下是访问WSDL时在SoapUI中生成的请求。
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<READ_WRITE_REQ_IN_GBO xmlns="http://example.com/getBalance">
<MetaInfo>
<ConsumerReqInfo xmlns="http://pqr.com/">
<circleId>MP</circleId>
<serviceName>ABC</serviceName>
<channelName>SCRM</channelName>
<segment>POSTPAID</segment>
</ConsumerReqInfo>
</MetaInfo>
</READ_WRITE_REQ_IN_GBO>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
现在,我正在尝试使用soap node js模块生成相同的xml。 节点JS代码:
var request = {
"MetaInfo" : {
"ConsumerReqInfo": {
"circleId":["MP"],
"serviceName":"ABC",
"channelName":["SCRM"],
"segment":["POSTPAID"]
}
}
}
var urlGetAccBal = 'http://localhost:8080/axis2/services/GetAccountBalance?wsdl';
soap.createClient(urlGetAccBal, function(err, client) {
if(err){
console.log("## Error : "+err);
} else {
client.GetAccountBalanceOperation(request,function(err, result){
if(err){
console.log("## Error : "+err);
} else {
console.log("## Result : "+JSON.stringify(result));
}
});
}
});
但是它会在xml下面生成
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://example.com/getBalance"><soap:Body>
<tns:READ_WRITE_REQ_IN_GBO>
<MetaInfo>
<ConsumerReqInfo>
<circleId>MP</circleId>
<serviceName>ABC</serviceName>
<channelName>SCRM</channelName>
<segment>POSTPAID</segment>
</ConsumerReqInfo>
</MetaInfo>
</tns:READ_WRITE_REQ_IN_GBO>
</soap:Body>
</soap:Envelope>
所以我的问题是,如何向ConsumerReqInfo
元素添加名称空间而不是根名称空间?
如果我使用wsdl选项:overrideRootElement
,它将更改根名称空间。
有什么解决办法吗?