2014-09-10 53 views
0

我试图通过使用SOAP服务 我用下面的代码做导入使用XML数据到数据库中,但它给我的错误数据导入数据库: 未知请求,无法处理 我从SOAP服务的XML格式要打发数据请 这一点,让我知道我在哪里弄错如何使用XML

Here is my code : 

     String SOAP_ACTION = "http://LocalHOST/LISTOFLEDGERS/NAME"; 

     String URL = "http://LocalHOST:portname"; 
     String response = null; 
     try { 
      HttpClient httpClient = new DefaultHttpClient(); 
      HttpPost httpPost = new HttpPost(URL); 

      String bodyOut = "<soapenv:Envelope>" 
        + "<soapenv:Header>" 
        + "<soapenv:Version>1</soapenv:Version>" 
        + "<soapenv:Tallyrequest>Import</soapenv:Tallyrequest>" 
        + "<soapenv:Type>Data</soapenv:Type>" 
        + "<soapenv:Id>All Masters</soapenv:Id>" 
        + "</soapenv:Header>" 
        + "<soapenv:Body>" 
        + "<soapenv:Desc>" 
        + "<soapenv:Staticvariables>" 
        + "<soapenv:Svexportformat>$$SysName:XML</soapenv:Svexportformat>" 
        + "</soapenv:Staticvariables>" + "</soapenv:Desc>" 
        + "<soapenv:Data>" + "<soapenv:Tallymessage>" 
        + "<soapenv:Ledger Name=" + "" + "Travelling EXp" + ">" 
        + "<soapenv:NAME.LIST>" 
        + "<soapenv:NAME>EXp</NAME>" 
        + "</soapenv:NAME.LIST>" + "</soapenv:Ledger>" 
        + "</soapenv:Tallymessage>" + "</soapenv:DATA>" 
        + "</soapenv:BODY>" + "</soapenv:ENVELOPE>"; 

      StringEntity se = new StringEntity(bodyOut, HTTP.UTF_8); 
      se.setContentType("text/xml"); 
      httpPost.addHeader("SOAPAction", SOAP_ACTION); 
      httpPost.setEntity(se); 

      HttpResponse httpResponse = httpClient.execute(httpPost); 
      HttpEntity resEntity = httpResponse.getEntity(); 
      response = EntityUtils.toString(resEntity); 
      Log.v("getting response#######################", response); 

    my xml one line is going +"<LEDGER NAME=EXp>"+ 
    it should be go like +"<LEDGER NAME="EXp">"+ so how i can do that 

回答

1

使用协商SQUENCE

Java Escape Sequence

"<LEDGER NAME=\"EXp\">" 
+0

感谢这个工作,但还是错误是一样的:未知请求,无法处理 – Kirti 2014-09-10 12:33:58

+0

现在的数据会在适当的格式,但仍然错误是一样 – Kirti 2014-09-10 12:34:13

+0

我不知道SOAP,所以我不能帮你了。但我建议你通过使用这个工具http://sourceforge.net/projects/soapui/来测试webservice而无需开发。也许它会给你更多关于错误的信息 – Kamil 2014-09-10 12:39:12