我使用ksoap / ksoap2 api从j2me调用php webservice。
对于ksoap:
SoapObject client = new SoapObject(NAMESPACE, "ns2221:save_record");
client.addProperty("cc", "1234560789");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XmlWriter xw = new XmlWriter(new OutputStreamWriter(bos));
SoapEnvelope envelope = new SoapEnvelope(new ClassMap(Soap.VER11));
envelope.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
envelope.setBody(client);
envelope.write(xw);
xw.flush();
bos.write('\r');
bos.write('\n');
byte[] requestData = bos.toByteArray();
String requestSOAPmesg = new String(requestData);
System.out.println("request Soap Message: " + requestSOAPmesg);
HttpTransport ht = new HttpTransport();
ht.setUrl(url);
ht.setSoapAction(NAMESPACE);
SoapObject o = (SoapObject) ht.call(client);
已经使用..
和ksoap2
SoapObject client = new SoapObject("http://192.168.0.205:82/imageuploader/save_record.php#save_record", "ns8862:save_record");
client.addProperty("cc", "1234560789");
//Create Envelope for
Object so=soapMsg;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=false;
envelope.bodyOut=client;
System.out.println("Before Envelope");
HttpTransport ht = new HttpTransport(url);
ht.call("http://192.168.0.205:82/imageuploader/save_record.php#save_record", envelope);
SoapObject o=(SoapObject) envelope.getResponse();
已经使用..
它让我回头
错误字符串:
faultstring:'操作'ns8862:save_record'未在此服务的WSDL中定义'faultactor:''detail:org.kxml2.kdom.Node@ea0ef881
在Web服务中,第一个标记ns8862:save_record每次传递4个数字的请求时都会更改。
任何解决方案?
答案 0 :(得分:1)
检查网络服务是否有大写字母。该错误表明“save_record”未定义。也许是“Save_Record”或“saveRecord”。确保您遵守模板。