帮助我,我正在搜索整个www大约3周,并且无法使其正常工作!
我有一个WS,只是想让我的应用程序得到响应。但是我在纠正一切后不幸总是得到了下面的错误!
08-09 15:29:30.930: INFO/System.out(1800): That is the bodyin envelope: SoapFault - Faultcode: 'env:Server'
faultstring: 'javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Apgame").
Expected elements are
<{http://master.system.com.br/}Apgame>,
<{http://master.system.com.br/}numberSerie>,
<{http://master.system.com.br/}idPost>,
faultactor: 'null' detail: null
我的应用正在使用此功能。
private void getSOAPRequest() {
//no matter what I put here in SOAP_ACTION it makes no difference
String SOAP_ACTION = "http://master.system.com.br/";
String NAMESPACE = "http://system.com.br/";
String METHOD_NAME = "GetPrice";
String URL = "http://12.12.12.111/MasterWS/GetPrice?WSDL";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Apgame", "8");
request.addProperty("numberSerie", "31345");
request.addProperty("idPost", "4");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try { androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();}
System.out.println("That is the bodyin envelope: "+ envelope.bodyIn);
}
我有SOAP UI,我可以在没有问题的情况下调用WS。
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tran="http://master.system.com.br/"
xmlns:ws="http://system.com.br/">
<soapenv:Body>
<ws:GetPrice>
<tran:Apgame>8</tran:Apgame>
<tran:numberSerie>31345</tran:numberSerie>
<tran:idPost>4</tran:idPost>
</ws:GetPrice>
</soapenv:Body>
</soapenv:Envelope>
我尝试了不同的Ksoap库,不同的命名空间,method_name。 Diferent SoapEnvelope.VER。我记不起我测试过的一切了。我很绝望。
非常感谢你..
答案 0 :(得分:0)
这样做:
String SOAP_ACTION = "http://master.system.com.br/";
String NAMESPACE = "http://system.com.br/";
String METHOD_NAME = "GetPrice";
String URL = "http://12.12.12.111/MasterWS/GetPrice?WSDL";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Apgame", "8");
request.addProperty("numberSerie", "31345");
request.addProperty("idPost", "4");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
try
{
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
}
catch (Exception e)
{
}
如果您的Uri变量是正确的,这应该可以解决问题。
答案 1 :(得分:0)
您必须为每个属性提供命名空间。试试addProperty
的重载版本,并为每个媒体设置包含PropertyInfo
和name
的{{1}}。
类似的东西:
namespace