Как потреблять Svc WCF сервис в Android

URL WSDL: http://xxx.xxx.xxx/UserService.svc

Я использовал Ksoap, чтобы поразить службу...

Это мой код:

try {
                request = new SoapObject("http://tempuri.org/", "GetUserDetailsByUserName");

                request.addProperty("username", "Prasad");
                envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet = true;
                envelope.setOutputSoapObject(request);
                Log.i("Wsdl Response", "Wsdl Response:");
                // request.setHeader("Content-type", "application/xml");
                // Proxy px = new Proxy();

                // ?singleWsdl
                httpreq = new HttpTransportSE("http://xxx.xxx.xxx/UserService.svc");
                httpreq.debug = true;
                httpreq.call("http://tempuri.org/xxxe/GetUserDetailsByUserName", envelope);
                Log.i("Wsdl Response", ":Wsdl Response:123");
                String xml = (String) envelope.getResponse().toString();
                SoapPrimitive results = (SoapPrimitive) envelope.getResponse();
                /*
                 * if (envelope.bodyIn instanceof SoapFault) { String errormessage = ((SoapFault) envelope.bodyIn).faultstring; throw new Exception(errormessage); } IncomeLeadXMLPharsing parse = new IncomeLeadXMLPharsing(); parse.parse(xml); ResultVecotor = parse.getVector(); mHandler.post(setValuesToUi);
                 */
                Log.i("Wsdl Response", ":Wsdl Response:" + xml);
                if (progress != null) {
                    if (progress.isShowing()) {
                        progress.dismiss();
                    }
                }


            }
            catch (UnknownHostException e) {
                if (progress != null) {
                    if (progress.isShowing()) {
                        progress.dismiss();
                    }
                }
                e.printStackTrace();
            }
            catch (ConnectException e) {
                if (progress != null) {
                    if (progress.isShowing()) {
                        progress.dismiss();
                    }
                }
                e.printStackTrace();
            }
            catch (SocketException e) {
                if (progress != null) {
                    if (progress.isShowing()) {
                        progress.dismiss();
                    }
                }
                e.printStackTrace();
            }
            catch (Exception e) {
                if (progress != null) {
                    if (progress.isShowing()) {
                        progress.dismiss();
                    }
                }
                e.printStackTrace();
                System.out.print("EXCEPTION" + e);
            }

но я получаю это исключение в журнале: я могу найти решение даже после огромной попытки

05-07 10:29:22.861: WARN/System.err(635): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@3:44 in java.io.InputStreamReader@413016e0) 
05-07 10:29:22.861: WARN/System.err(635):     at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
05-07 10:29:22.861: WARN/System.err(635):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
05-07 10:29:22.861: WARN/System.err(635):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
05-07 10:29:22.871: WARN/System.err(635):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:195)
05-07 10:29:22.871: WARN/System.err(635):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
05-07 10:29:22.871: WARN/System.err(635):     at com.myApp.JsonService$SampleWsdlServiceAsync.doInBackground(JsonService.java:291)
05-07 10:29:22.871: WARN/System.err(635):     at com.myApp.JsonService$SampleWsdlServiceAsync.doInBackground(JsonService.java:1)
05-07 10:29:22.871: WARN/System.err(635):     at android.os.AsyncTask$2.call(AsyncTask.java:264)
05-07 10:29:22.881: WARN/System.err(635):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-07 10:29:22.881: WARN/System.err(635):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-07 10:29:22.881: WARN/System.err(635):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
05-07 10:29:22.894: WARN/System.err(635):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
05-07 10:29:22.894: WARN/System.err(635):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
05-07 10:29:22.902: WARN/System.err(635):     at java.lang.Thread.run(Thread.java:856)

Будет здорово, если кто-нибудь поможет мне.

Заранее спасибо.

1 ответ

Попробуйте изменить эти строки:

Я думаю, что ваш URL-адрес вызова не является правильным:

try {                

 androidHttpTransport.call("http://tempuri.org/GetUserDetailsByUserName", Envelope);
} catch (IOException e) {
 Log.d("ErrorApp", e.getMessage().toString());
} catch (XmlPullParserException e) {
 Log.d("ErrorApp", e.getMessage().toString());

}

SoapPrimitive response= (SoapPrimitive) Envelope.getResponse();
Другие вопросы по тегам