2013-02-15 97 views
2

我一直在使用kso​​ap庫來使用.net Web服務。 「(在[email protected] 7位:START_TAG @ 1)預計START_TAG {} http://schemas.xmlsoap.org/soap/envelope/信封」使用KSoap庫來使用.NET Web服務時出現錯誤

我已搜查 和我得到這樣的錯誤

的每一個地方,但我找不到任何好的幫助。

這裏是我嘗試使用Web服務的代碼。

public class WebInvoke { 

    private static final String NAMESPACE = "http://tempuri.org/" ; 
    private static final String METHOD_NAME = "login"; 
    private static final String SOAP_ACTION = NAMESPACE + METHOD_NAME; 
    private static final String URL = "http://10.0.2.2/Service1.asmx"; 
    private final SoapSerializationEnvelope envelope; 


    public WebInvoke() 
    { 
     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

     PropertyInfo quotesProperty = new PropertyInfo(); 
     quotesProperty.setName("UserName"); 
     quotesProperty.setValue("admin"); 
     quotesProperty.setType(String.class); 
     request.addProperty(quotesProperty); 

     quotesProperty = new PropertyInfo(); 
     quotesProperty.setName("Password"); 
     quotesProperty.setValue("a"); 
     quotesProperty.setType(String.class); 
     request.addProperty(quotesProperty); 

     Log.e("Request Assign", request.toString()); 
     envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; 
     envelope.setOutputSoapObject(request); 
     Log.e("Envelope Assign", envelope.toString()); 
    } 
    public String Fetch() 
    { 
     String result = ""; 
     HttpTransportSE httpRequest = new HttpTransportSE(URL); 
     try 
     { 
      envelope.xsd = SoapSerializationEnvelope.XSD; 
      envelope.enc = SoapSerializationEnvelope.ENC; 

      httpRequest.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 

      Log.e("httpRequest.call", "httpRequest.call"); 
      httpRequest.call(SOAP_ACTION, envelope); 
      SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); 
      result = response.toString(); 
     } 
     catch(Exception e) 
     { 
      //e.printStackTrace(); 
      Log.e("httpRequest.call Exception", e.getMessage()); 
     } 
     return result; 
    } 

} 

回答

0

我也有這個錯誤。最終,它通過設置這些值得到修復:

String SOAP_ACTION = "BookTypeService"; 

String METHOD_NAME = "bookType"; 

String NAMESPACE = "http://192.168.1.3:8080/MyWebService/services/"; 

String URL = "http://192.168.1.3:8080/MyWebService/services/BookTypeService"; 

其中,192.168.1.3是我的本地I/P。

<wsdl:service name="BookTypeServiceService"> 
<wsdl:port name="BookTypeService" binding="impl:BookTypeServiceSoapBinding"> 
<wsdlsoap:address location="http://localhost:8080/MyWebService/services/BookTypeService"/> 
</wsdl:port> 
</wsdl:service> 
相關問題