我的代码是:
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
Object response = envelope.getResponse();
System.out.println("response : " + response.toString());
}
控制台中显示的响应:
03-21 14:23:30.532: INFO/System.out(4311): response : Map{item=anyType{key=2; value=Apple; }; item=anyType{key=1; value=Orange; }; }
我如何解析这个 JSOn 对象.. 我试过了
JSONObject jObject = new JSONObject( response.toString());
但抛出异常:
03-21 14:17:03.423: WARN/System.err(4210): org.json.JSONException: Value Map of type java.lang.String cannot be converted to JSONObject
我的网络服务方法:
public JSONObject getContactNames(){
JSONObject names = load();
System.out.println("names "+names);
return names;
}
WSDL:
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://service.asset.ey.com" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getContactNames">
<complexType/>
</element>
<element name="getContactNamesResponse">
<complexType>
<sequence>
<element name="getContactNamesReturn" type="xsd:anyType"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="getContactNamesRequest">
<wsdl:part element="impl:getContactNames" name="parameters"/>
</wsdl:message>
<wsdl:message name="getContactNamesResponse">
<wsdl:part element="impl:getContactNamesResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="ContactDetails">
<wsdl:operation name="getContactNames">
<wsdl:input message="impl:getContactNamesRequest" name="getContactNamesRequest"/>
<wsdl:output message="impl:getContactNamesResponse" name="getContactNamesResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ContactDetailsSoapBinding" type="impl:ContactDetails">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getContactNames">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getContactNamesRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getContactNamesResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
请帮助解析响应: