0

我正在使用 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: '' 详细信息: org.kxml2.kdom.Node@ea0ef881

在 Web 服务中,第一个标签 ns8862:save_record 每次通过 4 个数字的请求时都会发生变化。

任何解决方案?

4

1 回答 1

1

检查 Web 服务是否有大写字母。该错误表明“save_record”未定义。也许是“Save_Record”或“saveRecord”。确保您遵守模板。

于 2010-03-03T14:52:14.117 回答