android上的SOAP web服务
我正在尝试使用ksoap2库连接到SOAP web服务。我已经读了很多关于它的文档,但是我被卡住了,因为我的请求不是一个普通的请求 在发送请求之前,我需要指定一些头 当使用soap客户端测试Web服务时,我还需要将其放在soap enveope标头部分:android上的SOAP web服务,android,web-services,authentication,soap,ksoap2,Android,Web Services,Authentication,Soap,Ksoap2,我正在尝试使用ksoap2库连接到SOAP web服务。我已经读了很多关于它的文档,但是我被卡住了,因为我的请求不是一个普通的请求 在发送请求之前,我需要指定一些头 当使用soap客户端测试Web服务时,我还需要将其放在soap enveope标头部分: <SOAP-ENV:Header> <mns:AuthIn xmlns:mns="http://enablon/wsdl/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.or
<SOAP-ENV:Header>
<mns:AuthIn xmlns:mns="http://enablon/wsdl/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<UserInfo xsi:type="wsdlns:AuthHeader">
<EnaHomeSite xsi:type="xsd:string">sss</EnaHomeSite>
<EnaUserName xsi:type="xsd:string">sadsa</EnaUserName>
<EnaPassword xsi:type="xsd:string">qwertf</EnaPassword>
</UserInfo>
</mns:AuthIn>
</SOAP-ENV:Header>
sss
萨萨
qwertf
我的代码的其余部分与方法类似
emulator需要一点时间来处理,因此我假设它会与服务器联系,但对…调用的调用会与以下内容发生冲突:
org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}SOAP-ENV:Fault>@1:505 in java.io.InputStreamReader@43ef45e8)
org.xmlpull.v1.XmlPullParserException:应为:END_标记{http://schemas.xmlsoap.org/soap/envelope/}主体(位置:java.io中的END_标记@1:505)。InputStreamReader@43ef45e8)
我的问题是如何将上面提到的标题附加到我的请求
我没能为ksoap找到好医生。可能是一些教程或示例。有人能给我指一些文件吗。我找到了javadoc,但是它很薄
我还尝试格式化自己的原始HTTP请求。(在iPhone上成功做到了这一点,而且效果很好)。但是,我似乎无法在中添加请求主体。我指的是包含所有标题、名称空间和调用所需数据的大型soap xml。任何指向这个方向的指针都将不胜感激
非常感谢,伙计们
干杯,
Alex我遇到了同样的问题,为此我用以下方式创建了标题
并将此标题添加为
soapEnvelope.headerOut=addheader()代码>
因为它是为我工作,如果应该为你工作
public static Element[] addheader()
{
Element[] header = new Element[1];
header[0] = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security");
header[0].setAttribute(null, "mustUnderstand","1");
Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");
// usernametoken.addChild(Node.TEXT,"");
usernametoken.setAttribute("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "UsernameToken-4");
header[0].addChild(Node.ELEMENT,usernametoken);
Element username = new Element().createElement(null, "n0:Username");
username.addChild(Node.TEXT, "username_value");
//username.setPrefix("n0", null);
usernametoken.addChild(Node.ELEMENT, username);
Element pass = new Element().createElement(null, "n0:Password");
//pass.setPrefix("n0",null);
pass.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
pass.addChild(Node.TEXT, "password_value");
usernametoken.addChild(Node.ELEMENT, pass);
return header;
}