java - SAAJ: how to create child elements for SoapHeaderElement -
trying post data remote machine, returns fault
<soapenv:fault> <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:client.nosoapaction</faultcode> <faultstring>no soapaction header!</faultstring>
my gues there problem in way sending header elements:
// 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");
from response, clear soap toolkit on remote machine axis, , final request sent , response looks this:
<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>
i've gone through soap's documentation million times , valid soap request.
want know whether header child elements part defined.
if problem of authentication on axis?
in context, "header" doesn't refer soap header, http header. saaj, soapaction
header set follows:
mimeheaders headers = message.getmimeheaders(); headers.addheader("soapaction", "http://www.example.org/someaction");
message
soapmessage
object. soap action specified in wsdl of service.
Comments
Post a Comment