KSoap2 Android使用WCF给出错误

时间:2015-05-24 15:46:43

标签: android wcf

我尝试在Android中使用WCF消费KSoap2 3.4.0服务。

Service托管在http://cloudypost.com/StockListsWS.svc,它有一个方法SayHi,可以通过http://cloudypost.com/StockListsWS.svc/Sayhi/Manish访问

我正在尝试在我的Android代码中使用它。

private void SendRegIDToDB() {
         String METHOD_NAME = "SayHi";
         String NAMESPACE = "http://tempuri.org/";
         String URL = "http://cloudypost.com/StockListsWS.svc";
         String SOAP_ACTION = "http://tempuri.org/SayHi";

        try {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

            // 2. Define the property
            PropertyInfo property = new PropertyInfo();
            //property.setNamespace("http://ws.cdyne.com/WeatherWS/"); // namespace to ensure that the element-name is prefixed with the namespace
            property.setName("name"); // name of the argument as per wsdl document
            property.setValue("manish"); // value of the property
            request.addProperty(property);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);


            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive result = (SoapPrimitive) envelope.getResponse();

            //to get the data
            String resultData = result.toString();
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

让我知道上面代码中的错误。

1 个答案:

答案 0 :(得分:1)

您的AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))我的朋友未与http://cloudypost.com/StockListsWS.svc指南保持一致。尝试将您的项目2 SOAP导入wsdls,您将看到它无法提取任何API存根。

  

http://cloudypost.com/StockListsWS.svc?wsdl

     

http://cloudypost.com/StockListsWS.svc?singleWsdl

现在,您尝试使用http://www.service-repository.com/中的任何正常运行SoapUI并尝试使用Web ServiceSoapUI中创建一个新项目,您将看到差异。

enter image description here

您的客户端代码没有问题,但问题肯定在于您的xyz?wsdl