Как добавить свойства к этому мылу wsdl android - PullRequest
3 голосов
/ 14 июля 2011

Мое мыло 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 = новый 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"

Спасибо

Ответы [ 2 ]

2 голосов
/ 15 июля 2011

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


                    }

сейчас работает ..

спасибо

1 голос
/ 15 июля 2011

Вы смотрели на эту ссылку

public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, 
              String NAMESPACE, String URL) 
                 throws IOException, XmlPullParserException {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //set up request

    request.addProperty("iTopN", "5"); //variable name, value. 
     //I got the variable name, from the wsdl file!

    SoapSerializationEnvelope envelope = 
                   new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    //put all required data into a soap envelope

    envelope.setOutputSoapObject(request);  //prepare request

    AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);  

    httpTransport.debug = true;  //this is optional, 
    //use it if you don't want to use a packet sniffer to check what 
    //the sent message was (httpTransport.requestDump)

    httpTransport.call(SOAP_ACTION, envelope); //send request

    SoapObject result=(SoapObject)envelope.getResponse(); //get response

    return result;

  }
...