2011-07-14 12 views
3

マイソープWSDLは次のとおりです。 この石鹸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 [email protected]:0 in [email protected]) 

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" 

おかげ

+0

は正しく作成されたXMLですか? – jsp

+0

はい、SOAPのUIでチェックされています。その中で応答を得ています – Udaykiran

+0

あなたが参照しているWebサービスメソッドとは何ですか? – jsp

答えて

2

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


        } 

そのは今働いて..

ありがとう

+0

@Udaykiran ....ねえUdayさん、ありがとうございました... URコードは私をたくさん助けました...ありがとうトン.... – Taruni

+0

あなたのようなおかげで.. – Udaykiran

+0

私はこのコードに問題があります。いくつかのWebサービスのために働いていますが、いくつかのサービスでは空の応答を取り戻しています。ワットは問題? – Taruni

1

は、あなたがこのlink

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; 

    } 
+0

はい、しかしorg.xmlpull.v1.XmlPullParserExceptionを取得しています:予期しない型(位置:END_DOCUMENT null @ 1:0 [email protected]) – Udaykiran

+0

は正しいwebservice URLです。 ..それは有効でないときにその例外を見たことがある – jsp

+0

はい、その正しいとその方法を見ています – Udaykiran