我试图向我的服务器提交一个用户名和手机的设备ID,但是我一直收到以下错误:
W/System.err: SoapFault -故障代码:'soap:Client‘错误字符串:’解编组错误:意外元素(uri:"http://eventmanagement.management.de/",local:"username")。
这是我的密码:
PropertyInfo pi = new PropertyInfo();
pi.setNamespace(NAMESPACE);
pi.setName("username");
pi.setValue(userName.getText().toString());
pi.setType(PropertyInfo.STRING_CLASS);
request.addProperty(pi);
pi.setNamespace(NAMESPACE);
pi.setName("deviceID");
pi.setValue(android.provider.Settings.Secure.getString(
getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID));
pi.setType(PropertyInfo.STRING_CLASS);
request.addProperty(pi);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);这是wsdl文件:
<xs:complexType name="addUser">
<xs:sequence>
<xs:element minOccurs="0" name="username" type="xs:string"/>
<xs:element minOccurs="0" name="deviceID" type="xs:string"/>
</xs:sequence>
</xs:complexType>有人能帮我吗?我找了两个小时,什么也没找到。
Edit2:左上角,http-请求转储,右角,SoapUI生成的请求,它工作png.htm。
发布于 2015-06-09 08:34:26
您是否尝试过简单地使用下面的addProperty添加属性
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("username", username);
request.addProperty("deviceID", deviceID);此外,您还可以确保您有一个有效值,并且在访问NPE时没有碰到任何userName.getText().toString()。
发布于 2015-06-09 08:11:16
在添加第一个属性后,您应该记住将您的属性声明为新属性。
pi =新的PropertyInfo();
PropertyInfo pi = new PropertyInfo();
pi.setNamespace(NAMESPACE);
pi.setName("username");
pi.setValue(userName.getText().toString());
pi.setType(PropertyInfo.STRING_CLASS);
request.addProperty(pi);
// here
pi = new PropertyInfo();
pi.setNamespace(NAMESPACE);
pi.setName("deviceID");
pi.setValue(android.provider.Settings.Secure.getString(
getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID));
pi.setType(PropertyInfo.STRING_CLASS);
request.addProperty(pi);还有一件事,记得叫你的androidHttpTransport
androidHttpTransport.call(SOAP_ACTION,envelope,null);
SoapPrimitive respond = (SoapPrimitive) envelope.getResponse();更新:您的请求是否传入您想要的确切参数?调试时,您可以看到webservice名称以及传入的值名称和参数。
ConnectionString{username=manager;password=password123;}
https://stackoverflow.com/questions/30725975
复制相似问题