1
我试图使用https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdlAndroid的ksoap2请求导致HTTP 500
我写了下面的测试代码描述Web服务:
private static final String NAMESPACE = "http://swea.riksbank.se/ws";
private static final String METHOD_NAME = "getInterestAndExchangeGroupNames";
private static final String SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;
private static final String URL = "https://swea.riksbank.se:443/sweaWS/services/SweaWebServiceHttpSoap12Endpoint";
private void testService(){
HttpTransportSE androidHttpTransport = null;
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo groupid = new PropertyInfo();
groupid.setValue(5);
groupid.setType(PropertyInfo.INTEGER_CLASS);
groupid.setName("groupid");
PropertyInfo languageid = new PropertyInfo();
languageid.setValue("sv");
languageid.setType(PropertyInfo.STRING_CLASS);
languageid.setName("languageid");
request.addProperty(groupid);
request.addProperty(languageid);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);
androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
//SoapObject result = (SoapObject)envelope.getResponse();
}
catch (Exception e) {
Log.e("SOAP_TEST", "========= Request start =========");
Log.e("SOAP_TEST", androidHttpTransport.requestDump);
Log.e("SOAP_TEST", "========== Request end ==========");
Log.e("SOAP_TEST", "========= Response start ========");
Log.e("SOAP_TEST", androidHttpTransport.responseDump);
Log.e("SOAP_TEST", "========== Response end =========");
Log.e("SOAP_TEST", e.toString());
Log.e("SOAP_TEST", e.getMessage());
}
}
测试代码将导致HTTP状态500
当我检查请求转储请求XML是这样的:
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://www.w3.org/2003/05/soap-encoding" xmlns:v="http://www.w3.org/2003/05/soap-envelope">
<v:Header />
<v:Body>
<n0:getInterestAndExchangeGroupNames id="o0" c:root="1" xmlns:n0="http://swea.riksbank.se/ws">
<groupid i:type="d:int">5</groupid>
<languageid i:type="d:string">sv</languageid>
</n0:getInterestAndExchangeGroupNames>
</v:Body>
</v:Envelope>
我还引进了WSDL到的soapUI,这将产生以下请求:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://swea.riksbank.se/xsd">
<soap:Header/>
<soap:Body>
<xsd:getInterestAndExchangeNames>
<groupid>5</groupid>
<languageid>sv</languageid>
</xsd:getInterestAndExchangeNames>
</soap:Body>
</soap:Envelope>
该请求看起来完全作为Web服务文档中的描述,也按预期工作。
那么做我需要做修复ksoap2要求? (这肥皂的东西对我来说是全新的。)