0
正在尝试一些数据发布到远程机器,但它返回一个错误
SAAJ:如何创建子元素的SOAPHeaderElement
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
<faultstring>no SOAPAction header!</faultstring>
我客串是存在方式的问题,我正在发送我的头元素:
// Java code snip
SOAPHeader header = envelope.getHeader();
header.setPrefix("soapenv");
QName headerElementName = new QName("http://soft.com/webservices/", "AuthHeader");
SOAPHeaderElement authHeader = header.addHeaderElement(headerElementName);
QName headerChild = new QName("Username");
SOAPElement userName = authHeader.addChildElement(headerChild);
userName.addTextNode("smart");
headerChild = new QName("Password");
SOAPElement passwd = authHeader.addChildElement(headerChild);
passwd.addTextNode("smart");
从响应,其清楚的是,远程机器上的肥皂工具包是轴,和发送的最后请求及其响应看起来像这样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ocs="http://ocs.soft.com">
<soapenv:Header>
<AuthHeader xmlns="http://soft.com/webservices/">
<Username>smart</Username>
<Password>smart</Password>
</AuthHeader>
</soapenv:Header>
<soapenv:Body><ocs:doService><ocs:in0 xmlns:ocs="http://ocs.soft.com"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<zsmart>
<Data>
<header>
<ACTION_ID>ModifyBalReturnAllBal</ACTION_ID>
<REQUEST_ID>005200907310022</REQUEST_ID>
</header>
<body>
<MSISDN>254775127966</MSISDN>
<AccountCode></AccountCode>
<BalID></BalID>
<AddBalance>10000</AddBalance>
<AddDays>0</AddDays>
<TransactionSN>00520090731002195</TransactionSN>
</body>
</Data>
</zsmart>
]]></ocs:in0></ocs:doService></soapenv:Body></soapenv:Envelope>
HTTP/1.1 500 Internal Server Error
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Wed, 20 Jan 2016 16:56:52 GMT
Server: Apache-Coyote/1.1
Connection: close
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
<faultstring>no SOAPAction header!</faultstring>
<detail>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">ocstest</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
我已经通过了肥皂的文件数百万次,并确定这是有效的肥皂请求。
我想知道我的标题子元素部分是否定义良好。
如果是这样,它是一个轴验证问题?