Android WSDL Web Service ksoap2

为君一笑 提交于 2019-11-27 16:24:12

I had similar problems in the past. I'll give you an example of a part i had to fix in my application and how i did, check if you did these steps in your case:
In the wsdl there was:

<message name="invokeService">
     <part name="serviceName" type="xsd:string"/>
     <part name="documents" type="tns:uriList"/>
     <part name="literalDocs" type="ns1:stringArray"/>
     <part name="connID" type="xsd:long"/>
     <part name="gateParams" type="tns:gateRuntimeParameterArray"/>
     <part name="userCtx" type="tns:userContext"/>
</message>


So I had to follow these steps:
1- check if your classes implementing KvmSerializable are accurately defined and not missing anything (this is cruciale for complex types)

2-Add ALL the necessary soap object properties that you need, for example in my case :

//for the part: <part name="serviceName" type="xsd:string"/>
SoapObject.addProperty("serviceName", whateverServiceNameItWas);

//for the part: <part name="documents" type="tns:uriList"/>,where uriList was a complex type
PropertyInfo pi = new PropertyInfo();
pi.setName("documents");
pi.setValue(usrOptPr.getDocuments());
pi.setType(UriList.class);
sobj.addProperty(pi);

etc... 3-Build the enveloppe:

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.setOutputSoapObject(SoapObject);

4- Add mappings between complex types(ie local class that implement kvmserializable, and the real matching classes on the web service)

//---------------------------------------------------------------------------------------
// MAPPINGS:
// A mapping tells the ksoap what class to generate.
// Complex data types that are not mapped are generated as SoapObjects.
// The mapping is required for both the request and the response.
 //---------------------------------------------------------------------------------------

//for example the UriList above     
soapEnvelope.addMapping(theNamespace, UriList.class.getSimpleName(), UriList.class);

5- Add marshalling:(Marshalling uses java serialization to change Objects to stream of data to be unmarshalled on the web service.)

Marshal floatMarshal = new MarshalFloat();
floatMarshal.register(soapEnvelope);

6- Use AndroidHttpTransport to call the web service
UPDATE
I also noticed that you have in the browser request:

<d4p1:Schools i:nil="true" />

While in Android:

<Schools i:type="d:string"></Schools>

Sometimes ksoap2 bugs with such a scenario, i had the same case so what i did is i just removed (commented out, since it allows nil ie null values) this param (ie schools) from its specific class that implements kvmserializable ( of course you will have to modify other stuff in the class like "getPropertyCount" and "getPropertyInfo" to adapt to this change). When i did that it worked, so try that and let me know.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!