gpt4 book ai didi

Android、Ksoap、网络服务

转载 作者:太空宇宙 更新时间:2023-11-03 11:21:53 24 4
gpt4 key购买 nike

帮帮我,我花了大约 3 周的时间搜索整个 www,但无法正常工作!

我有一个 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。不同的 SoapEnvelope.VER 。我不记得我测试过的所有内容。我很绝望。

非常感谢..

最佳答案

您必须为每个属性提供命名空间。尝试重载版本的 addProperty 并设置包含每个属性的 namenamespacePropertyInfo

类似于:

String TRAN_NAMESPACE = "http://master.system.com.br/";
...

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo apGame = new PropertyInfo();
apGame.name = "Apgame";
apGame.namespace = TRAN_NAMESPACE;
request.addProperty(apGame, "8");
...

关于Android、Ksoap、网络服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7002823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com