我遇到了使用来自ksoap2-android lib的SoapSerializationEnvelope创建的信封问题。我需要得到的(服务器期望的是):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soa="http://agh.edu.pl/soa">
<soapenv:Header/>
<soapenv:Body>
<soa:getCompanyById>
<id>1</id>
</soa:getCompanyById>
</soapenv:Body>
</soapenv:Envelope>
我真正得到的是:
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:getCompanyById id="o0" c:root="1" xmlns:n0="http://agh.edu.pl/soa">
<id i:type="d:int">5</id>
</n0:getCompanyById>
</v:Body>
</v:Envelope>
我的Java代码:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo id = new PropertyInfo();
id.setName("id");
id.setValue(5);
id.setType(int.class);
request.addProperty(id);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
try {
httpTransport.call(request.getNamespace() + "/" + request.getName(), envelope);
} catch (Exception e)
{
System.out.println(httpTransport.requestDump);
System.out.println(httpTransport.responseDump);
System.out.println(e.getMessage());
}
我需要做的是将每个v:some更改为soapenv:something和n0:getCompanyById进入soa:getCompanyById。任何的想法?提前致谢。 CYA
答案 0 :(得分:1)
这些信封大致相同 - 它们只使用不同的前缀。我建议使用像SoapUI这样的东西:一步一步,将工作范围改为你从代码中得到的东西。事情变得糟糕,你就会知道造成问题的原因。
根据我的经验 I:类型= “d:INT” 也可能导致问题。