0

我正在使用返回 xml 模式的 Web 服务。我想通过 SOAP 调用它。我已经对其进行了编码,但我没有得到任何输出。有人可以帮我吗?

我的网络服务是:

http://dev.sigwp.org/WikipediaOntologyAPIv4/Service.asmx?WSDL

4

2 回答 2

0

你的问题不是很清楚你真正想要什么,但如果你想使用 Android 的肥皂网络服务,你可以按照本教程

http://www.c-sharpcorner.com/UploadFile/88b6e5/how-to-call-web-service-in-android-using-soap/

于 2012-11-18T06:52:44.453 回答
0

我使用以下内容发出了登录的肥皂请求。根据您的需要修改相同的内容。确保您的项目 lib 中包含最新的 soap jar 文件。还可以查看本教程。http://www.youtube.com/watch?v=v9EowBVgwSo

    SoapObject request = new SoapObject("NameSpace", "MethodName");//
    loginreq.setValue("<LoginReq>" 
                        +"<nickName>"+name+"</nickName>" 
                        +"<password>"+pass+"</password>" 
                        +"<IMEI>"+mImei+"</IMEI>" 
                        +"<location>" 
                        +"<latitude>"+lati+"</latitude>"
                        +"<longitude>"+longi+"</longitude>"
                        +"</location>" 
                        +"</LoginReq>");//my requirement was to send request in this format.
   PropertyInfo loginreq = new PropertyInfo();
            loginreq.name="LoginReq";
            loginreq.type=String.class;
            request.addProperty(loginreq);  //sending request.
            SoapSerializationEnvelope envelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelop.setOutputSoapObject(request);
            System.out.println("Request is"+request); 

        HttpTransportSE androidHttpTransport = new   HttpTransportSE ("http://bugs.medalsystems.com:8080/ThirdEye/ThirdEyeWebService?wsdl");//your wsdl link
        androidHttpTransport.debug=true;

        try
        {
        androidHttpTransport.call("http://service.medal.org/ThirdEyeWebService/LoginRequest", envelop);
        SoapObject response=(SoapObject) envelop.bodyIn;
        System.out.println("Response is......"+response.toString());
   System.out.println("Response is......"+response.toString());

        DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(response.getProperty(0).toString()));

        Document doc = db.parse(is);//parse xml
        NodeList nodes = doc.getElementsByTagName("StandardResp");

        for (int i = 0; i < nodes.getLength(); i++) 
            {

              Element element = (Element) nodes.item(i);

              NodeList rc = element.getElementsByTagName("respCode").item(0).getChildNodes();//get value form respCode tag
              ResponseCode = ((Node) rc.item(0)).getNodeValue();
              System.out.println("Respone Code...."+ResponseCode);

              NodeList mess =  element.getElementsByTagName("message").item(0).getChildNodes();
              Message = ((Node) mess.item(0)).getNodeValue();
              System.out.println("Message....."+Message);

              NodeList sess =  element.getElementsByTagName("sessionId").item(0).getChildNodes();
              SessionIdlin = ((Node) sess.item(0)).getNodeValue();
              System.out.println("Session Id....."+SessionIdlin); 

            }

        }
        }
        catch(Exception e)
         {
      e.printStackTrace();
       }

解析 XML 模式 java

于 2012-11-18T06:58:34.267 回答