gpt4 book ai didi

android - org.xmlpull.v1.XmlPullParserException : unexpected type (position:END_DOCUMENT null@1:1 in Android KSOAP2, 但在 C# 中它正在工作

转载 作者:行者123 更新时间:2023-11-29 01:49:39 28 4
gpt4 key购买 nike

在访问 WCF (.svc) Web 服务时,我已经遇到此错误 2 周了。但是在 C# 中,当我将 Web 服务添加为服务引用时,它起作用了。

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:1 in     java.io.InputStreamReader@418188c0)

Web 服务的 targetNamespace=""urn:data.link.abc" 和方法的详细信息是

<wsdl:operation name="EncryptPassword">
<wsdl:input wsaw:Action="EncryptPassword" name="EncryptPasswordRequest" message="tns:EncryptPasswordRequest"/>
<wsdl:output wsaw:Action="urn:data.link.abc/ABCContract/EncryptPasswordResponse" name="EncryptPasswordReply" message="tns:EncryptPasswordReply"/>
</wsdl:operation>

这是我访问 .svc 网络服务的代码。

public final String web_serviceEncryptPassword(String password)
{
String NAMESPACE = "urn:data.link.abc";
String METHOD_NAME = "EncryptPassword";
String SOAP_ACTION = NAMESPACE + "/" + "EncryptPassword";
String URL = "http://192.168.20.254:8081/Service.svc"; //"http://192.168.20.254:8081/Service.svc?wsdl";

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
Object result = null;
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//request.addProperty("_Password", password);
PropertyInfo propertyInfo = new PropertyInfo();
propertyInfo.setName("arg0");
propertyInfo.setValue(password);
propertyInfo.setType(String.class);
request.addProperty(propertyInfo);


envelope.setOutputSoapObject(request);
envelope.bodyOut = request;

//They said they have an authorization, but same error still showed up when I added the header for the
//Authorization...
//List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
//String authentication = android.util.Base64.encodeToString(
// "user.a:password".getBytes(), android.util.Base64.NO_WRAP);
//headers.add(new HeaderProperty("Authorization", "Basic " + authentication));
//// headers.add(new HeaderProperty("Authorization", "user.a:password"));

androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);//, headers);
SoapObject response = (SoapObject) envelope.getResponse();
result = Boolean.parseBoolean(response.getProperty(0).toString());

}
catch (Exception E)
{
E.printStackTrace();
}

return result.toString();
}

我正在使用 ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar 作为我的 KSOAP2 库。

最佳答案

我在 (ver1.2) 行下面更改了相同的问题,问题已解决

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

关于android - org.xmlpull.v1.XmlPullParserException : unexpected type (position:END_DOCUMENT null@1:1 in Android KSOAP2, 但在 C# 中它正在工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19018067/

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