我在下面使用Ksoap2库发了一个soap请求。我在使用这段代码的时候得到了响应代码为403.I已搜索并发现Ksoap2库在android.But中与SOAP API集成时非常有用我无法弄清楚问题。
SOAP API请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="myUrl">
<soapenv:Header/>
<soapenv:Body>
<GetClients>
<Request>
<SourceCredentials>
<SourceName>{SourceName}</SourceName>
<Password>{Password}</Password>
<SiteIDs>
<int>{SiteID}</int>
</SiteIDs>
</SourceCredentials>
<XMLDetail>Full</XMLDetail>
<PageSize>0</PageSize>
<CurrentPageIndex>0</CurrentPageIndex>
</Request>
</GetClients>
</soapenv:Body>
</soapenv:Envelope>
我的Android代码是:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject sourcecredentials = new SoapObject(SOAP_ACTION, "SourceCredentials");
PropertyInfo info = new PropertyInfo();
info.setName("SourceName");
info.setValue("MySourceName");
sourcecredentials.addProperty(info);
PropertyInfo info2 = new PropertyInfo();
info2.setName("Password");
info2.setValue("myPassword");
sourcecredentials.addProperty(info2);
PropertyInfo info3 = new PropertyInfo();
info3.setName("SiteIDs");
info3.setValue(MySiteid);
sourcecredentials.addProperty(info3);
//This also I tried
/*SoapObject soapSiteids = new SoapObject(NAMESPACE, "SiteIDs");
soapSiteids.addProperty("int", MySiteId);
sourcecredentials.addProperty("SiteIDs",soapSiteids);*/
request.addProperty("SourceCredentials", sourcecredentials);
request.addProperty("XMLDetail", "Full");
request.addProperty("PageSize", "10");
request.addProperty("CurrentPageIndex", "0");
request.addProperty("ScheduleType", "Appointment");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSE = new HttpTransportSE("My WSDL Url");
try {
httpTransportSE.call(SOAP_ACTION, envelope);
SoapPrimitive soapPrimitive = (SoapPrimitive)envelope.getResponse();
result = soapPrimitive.toString();
} catch (Exception e) {
e.printStackTrace();
}
我正在做这样的403 http错误。如果我在上面的代码中做错了什么,请帮助我。谢谢提前
答案 0 :(得分:0)
当您调用服务并获得403错误时,可能会发生错误 由于以下原因。