【问题标题】:android SOAP parsingandroid SOAP 解析
【发布时间】:2011-03-14 13:34:06
【问题描述】:

这是我的 SOAP 网络服务:

POST /thehlb/mobile/mobileservice.asmx HTTP/1.1
Host: projects.spinxweb.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/CheckLogin"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CheckLogin xmlns="http://tempuri.org/">
      <UserName>string</UserName>
      <Password>string</Password>
      <PhoneType>string</PhoneType>
      <MoblieUniqueNo>string</MoblieUniqueNo>
    </CheckLogin>
  </soap:Body>
</soap:Envelope>

这是我的代码..

public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

      //CALL the web service method with the two parameters vname and nname
        SoapObject request = new SoapObject(NAMESPACE, METHOS_NAME);
        request.addProperty( "UserName","test@yahoo.com");
        request.addProperty("Password", "123");
        request.addProperty("PhoneType", "Android");
        request.addProperty("MoblieUniqueNo", "123456");

        SoapSerializationEnvelope envelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelop.setOutputSoapObject(request);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
        androidHttpTransport.debug = true;

        try
        {
            androidHttpTransport.call(SOAP_ACTION, envelop);

            // Get the SAOP Envelope back and the extract the body

            SoapObject resultsRequestSOAP  = (SoapObject) envelop.getResponse();
            System.out.println("Responce :"+resultsRequestSOAP.toString());
            Vector vector = (Vector) resultsRequestSOAP.getProperty("CheckLogin");

            //Count of the arrays beneath starting from 0
            SoapObject test = (SoapObject) vector.get(0);

            //Get the attributes in the array
            String uName = (String) test.getProperty("UserName");
            uName = uName + " " + (String)test.getProperty("Password");

            System.out.println("uname "+uName);


            //Just show it in a text area field called lblStatus
              TextView tv = (TextView) findViewById(R.id.textview); 
              tv.setText(uName.toString());

              System.out.println("user name :"+tv);

        }
        catch (Exception e) 
        {
            e.printStackTrace();
            System.out.println("Error :"+e);
        }

    } //end onCreate method

解析它时出错。有没有人有办法解决吗?请帮帮我。

【问题讨论】:

  • SoapFault - 故障代码:'System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.NullReferenceException:对象引用未设置为对象的实例。
  • 这是服务器错误。你的服务器代码是什么?
  • 对不起,我没有收到。我有搜索肥皂解析,我在大部分链接中都得到了这个结果。我的代码中还剩下哪个服务器代码?你有这方面的例子吗?

标签: android web-services parsing soap


【解决方案1】:

您可以尝试使用soapui 或其他一些工具来查看服务是否正常工作。然后,如果服务正常工作,请检查您放入的肥皂信封是否与 SoapUI 创建的相同(标签名称前缀完全不同)。如果有差异,请检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    • 2020-04-22
    • 1970-01-01
    相关资源
    最近更新 更多