Search code examples
androidksoap2

How to add properties to this soap wsdl android


My Soap wsdl is:

 <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>

Am using this code to add properties to respective tags.

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)));

but am getting the exception as:

  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) 

how to resolve this Issue?

methodnames:

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"

Thanks


Solution

  • Atlaaast I figured out :

     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);
    
    
                        }
    

    its working now..

    thanks