我必須連接SAP Web服務。這裏是我的代碼,但它警告:org.xmlpull.v1.XmlPullParserException:expected:START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope(position:START_TAG @ 1:7 in java.io.InputStreamReader @ 40e3fe98)如何使用ksoap2驗證SAP Web服務
這裏是我完整的代碼連接用戶名和密碼。 感謝您的回覆。
final static String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
final static String METHOD_NAME = "ZmblHucremalzemelistesi";
final static String SOAP_ACTION = "";
final static String URL = "http://xxx.xxx.xxx.xxx:1080/sap/bc/srt/wsdl/bndg_4F969242EA785040E10080008D0B0B03/wsdl11/allinone/ws_policy/document?sap-client=010";
private void testWS() {
// TODO Auto-generated method stub
SoapObject reSoapObject = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope soaSerializationEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
reSoapObject.addProperty("ILgort", "H12");
soaSerializationEnvelope.setOutputSoapObject(reSoapObject);
soaSerializationEnvelope.headerOut = new Element[1];
soaSerializationEnvelope.headerOut[0] = buildAuthHeader();
HttpTransportSE httpTransportSE = new HttpTransportSE(URL);
try {
httpTransportSE.call(SOAP_ACTION, soaSerializationEnvelope);
Object response = soaSerializationEnvelope.getResponse();
tv.setText(response.toString());
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}
private Element buildAuthHeader() {
Element h = new Element().createElement(NAMESPACE, "AuthHeader");
Element username = new Element().createElement(NAMESPACE, "user");
username.addChild(Node.TEXT, "testuser");
h.addChild(Node.ELEMENT, username);
Element pass = new Element().createElement(NAMESPACE, "pass");
pass.addChild(Node.TEXT, "testpwd");
h.addChild(Node.ELEMENT, pass);
return h;
}
我用這個帖子才達到但沒有解決http://stackoverflow.com/questions/5613675/how -to-設置皁集管使用-ksoap2-機器人 – 2012-04-25 13:28:02
並且當我設置URL作爲我的WSDL URL,我只得到anyType的{}導致 – 2012-04-25 14:08:09
並且還當我更換對象響應..線SoapObject響應=(SoapObject) SOA Seria ..我得到了ZmblHucremalzemelistesiResponse {THcrmlzlist = anyType {}; }結果:S – 2012-04-25 14:17:37