gpt4 book ai didi

java - SOAP org.xmlpull.v1.XmlPullParserException : expected: START_TAG

转载 作者:行者123 更新时间:2023-12-01 11:42:18 26 4
gpt4 key购买 nike

我尝试从网络服务调用网络方法“注册”。它包含一个输入参数和一个输出。

HttpTransportSE  httpTransport=null;

try
{
String organization = "Слоник Зеленый";

String method = "Registration";
SoapObject request = new SoapObject("http://www.ServiceDesk.org", method);

PropertyInfo pi1 = new PropertyInfo();
pi1.setName("Organisation");
pi1.setValue(organization);
pi1.setType(String.class);
request.addProperty(pi1);



SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //VER.10,VER.11,VER.12 don't help
envelope.setOutputSoapObject(request);
// envelope.implicitTypes = true; #don't help me

envelope.dotNet = false; # "true" value don't help
List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
headerList.add(new HeaderProperty("Authorization", "Basic " + org.kobjects.base64.Base64.encode("user:password".getBytes())));


httpTransport = new HttpTransportSE(MainAsync.wsdlSchema);

httpTransport.debug=true;
httpTransport.call("http://www.ServiceDesk.org#ServiceDesk:Registration", envelope,headerList);

SoapObject result =(SoapObject) envelope.bodyIn;
String roleId = result.getProperty("return").toString();

httpTransport.reset();

return roleId;
} catch (Exception e) {
Log.e(httpTransport.responseDump);
Log.e("Request "+httpTransport.requestDump);

e.printStackTrace();
if(httpTransport!=null)
httpTransport.reset();
return"";
} finally{
if(httpTransport!=null)
httpTransport.reset();
}

但是 om nethod 调用,我收到下一个错误:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <definitions name='ServiceDesk' targetNamespace='http://www.ServiceDesk.org'>@9:48 in java.io.InputStreamReader@76ed5528) 
at org.kxml2.io.KXmlParser.exception(KXmlParser.java:242)
at org.kxml2.io.KXmlParser.require(KXmlParser.java:1384)
at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:128)
at org.ksoap2.transport.Transport.parseResponse(Transport.java:118)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:275)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118)

这是我的 wsdl 文件:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12bind="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ServiceDesk.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://www.ServiceDesk.org" name="ServiceDesk" targetNamespace="http://www.ServiceDesk.org">
<types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs1="http://www.ServiceDesk.org" targetNamespace="http://www.ServiceDesk.org" elementFormDefault="qualified">
<xs:element name="Registration">
<xs:complexType>
<xs:sequence>
<xs:element name="Organisation" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</types>
<message name="RegistrationRequestMessage">
<part name="parameters" element="tns:Registration"/>
</message>
<message name="RegistrationResponseMessage">
<part name="parameters" element="tns:RegistrationResponse"/>
</message>
<portType name="ServiceDeskPortType">
<operation name="Registration">
<input message="tns:RegistrationRequestMessage"/>
<output message="tns:RegistrationResponseMessage"/>
</operation>
<binding name="ServiceDeskSoapBinding" type="tns:ServiceDeskPortType">
<soapbind:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Registration">
<soapbind:operation style="document" soapAction="http://www.ServiceDesk.org#ServiceDesk:Registration"/>
<input>
<soapbind:body use="literal"/>
</input>
<output>
<soapbind:body use="literal"/>
</output>
</operation>
</binding-name>
<service name="ServiceDesk">
<port name="ServiceDeskSoap" binding="tns:ServiceDeskSoapBinding">
<documentation>
<wsi:Claim xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/" conformsTo="http://ws-i.org/profiles/basic/1.1"/>
</documentation>
<soapbind:address location="http://volga.rarus.ru/abc2009_artur/ru/ws/ServiceDesk"/>
</port>
<port name="ServiceDeskSoap12" binding="tns:ServiceDeskSoap12Binding">
<soap12bind:address location="http://volga.rarus.ru/abc2009_artur/ru/ws/ServiceDesk"/>
</port>
</service>

我正在解析类似问题的 stackoverflow,但这对我没有帮助。

最佳答案

我尝试过这个并且对我来说是正确的:

嗯,我认为 NAMESPACE 字符串应该是 SoapObject 构造函数中的第一个参数。 call() 方法也是如此(这里应该是 NAMESPACE + METHOD_NAME 作为第一个参数)

试试这个:

_envelope.setOutputSoapObject(_client);

而不是这个:

_envelope.bodyOut = _client;

获取响应:这取决于您的 Web 服务返回的内容(原始对象还是复杂对象?)

来自this link的回答:

关于java - SOAP org.xmlpull.v1.XmlPullParserException : expected: START_TAG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29428388/

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