其他分享
首页 > 其他分享> > 如何向此肥皂wsdl android添加属性

如何向此肥皂wsdl android添加属性

作者:互联网

我的肥皂wsdl是:

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:AddTagDetails>
         <!--Optional:-->
         <tem:objtag>

            <tem:FKPersonID></tem:FKPersonID>
            <tem:FKConferenceID></tem:FKConferenceID>
            <!--Optional:-->
            <tem:TagName></tem:TagName>

            <tem:CreatedBy></tem:CreatedBy>

            <tem:ModifiedBy></tem:ModifiedBy>

         </tem:objtag>
      </tem:AddTagDetails>
   </soapenv:Body>
</soapenv:Envelope>

我正在使用此代码向各个标签添加属性.

SoapObject ad_property = new SoapObject(NAMESPACE2,METHOD_NAME2);

         ad_property.addProperty("FKPersonID", Integer.valueOf(userValues.get(0)));
         ad_property.addProperty("FKConferenceID", Integer.valueOf(userValues.get(4)));
         ad_property.addProperty("TagName", tagName.getText().toString());
         ad_property.addProperty("CreatedBy", Integer.valueOf(userValues.get(0)));
         ad_property.addProperty("ModifiedBy", Integer.valueOf(userValues.get(0)));

但由于以下原因而出现异常:

  07-15 02:03:29.401: WARN/System.err(583): org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@450624b8) 

如何解决这个问题?

方法名:

private static final String METHOD_NAME2 = "AddTagDetails";
    private static final String NAMESPACE2 = "http://tempuri.org/";
    private static final String URL2 = "http://xxxx.xxxxxx/TagService.asmx?wsdl";
    private static final String SOAP_ACTION2 = "http://tempuri.org/AddTagDetails"

谢谢

解决方法:

我发现了Atlaaast:

 URL u = new URL(URL2);
                 URLConnection uc = u.openConnection();
                 connection = (HttpURLConnection) uc;

                 connection.setDoOutput(true);
                 connection.setDoInput(true);
                 connection.setRequestProperty("SOAPAction", SOAP_ACTION2);
                 connection.setRequestMethod("POST");
                 connection.setRequestProperty("Content-type", "text/xml; charset=utf-8");




                 String xmldata = 

                                  "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"  xmlns:tem=\"http://tempuri.org/\"> "+ 
                                  "<soapenv:Header/>"+

                                  "<soapenv:Body>"+
                                  "<tem:AddTagDetails>"+

                                  "<tem:objtag>"+
                                  "<tem:FKPersonID>"+ Integer.valueOf(JujamaMain.userValues.get(0))+"</tem:FKPersonID>>"+
                                  "<tem:FKConferenceID>"+ Integer.valueOf(JujamaMain.userValues.get(4))+"</tem:FKConferenceID>"+
                                  "<tem:TagName>"+tagName.getText().toString()+"</tem:TagName>"+
                                  "<tem:CreatedBy>"+ Integer.valueOf(JujamaMain.userValues.get(0))+"</tem:CreatedBy>"+
                                  "<tem:ModifiedBy>"+ Integer.valueOf(JujamaMain.userValues.get(0))+"</tem:ModifiedBy>"+
                                  "</tem:objtag>"+

                                  "</tem:AddTagDetails>"+

                                  "</soapenv:Body>"+
                                  "</soapenv:Envelope>";        

                 System.out.println(xmldata);

                 OutputStream out = connection.getOutputStream();

                 Writer wout = new OutputStreamWriter(out);

                  wout.write(xmldata);

                    wout.flush();

                    wout.close();

                    BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    System.out.println("code..."+connection.getResponseCode());

                      //InputStream in = connection.getInputStream();

                      String result;
                  //int c;
                    while ((result=rd.readLine()) != null) {

                    System.out.println(result);


                    }

它现在正在工作..

谢谢

标签:ksoap2,android
来源: https://codeday.me/bug/20191208/2089426.html