2012-06-06 39 views
5

Dịch vụ web của tôi rõ ràng đang chạy xà phòng 1.2 (bằng cách kiểm tra .wsdl) và ive đang cố gắng truy cập vào dịch vụ web helloworld để thử nghiệm nhưng tôi đã gặp phải lỗi. Tôi đang cố gắng thực hiện điều này thông qua trình giả lập bằng cách này.xà phòng 1.2 android Vui lòng cung cấp một hành động xà phòng hợp lệ

Vì vậy, khi tôi sử dụng phiên bản 1.2 của xà phòng, tôi nhận được lỗi rằng "không thể xử lý yêu cầu mà không có thông số hành động hợp lệ. Vui lòng cung cấp xà phòng hợp lệ" Tôi muốn biết tôi đang thiếu gì và tôi nên làm gì .

Cảm ơn bạn!

Những điều tôi đã thực hiện:

  • Thêm phép cho android sử dụng internet
  • Thay đổi từ Xà phiên bản 1.1 và 1.2
  • Thay đổi từ SoapObject vào Object (đối với cả xà phòng 1.1 và 1.2)
  • Đã sử dụng 10.0.2.2 cho trình giả lập
  • Đã kiểm tra lỗi chính tả trong địa chỉ và tên phương thức

mã của tôi:

private static final String NAMESPACE = "http://localhost/WebService/"; 
private static final String URL = "http://10.0.2.2:1672/Eventurous/WsEventurousMobile.asmx"; 
private static final String HelloWorld_SOAP_ACTION = "http://localhost/WebService/HelloWorld"; 
private static final String METHOD_NAME1 = "HelloWorld"; 



... 
... 

public static String GetHelloWorld() { 

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
    SoapEnvelope.VER12); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000); 

    try { 
    androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 
    androidHttpTransport.call(HelloWorld_SOAP_ACTION, envelope); 

    SoapObject response = (SoapObject)envelope.getResponse(); 
    String result = response.getProperty(0).toString(); 

    return result; 
    } catch (Exception e) { 
    return e.toString(); 
    } 

} 

lỗi cho phiên bản Xà phòng 1,2

Code: soap:Sender, Reason: System.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action. 

at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() 

at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) 

at System.Web.Services.Protocols.SoapServerProtocol.Initialize() 

at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean 

lỗi cho phiên bản Xà phòng 1,1

SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost/WebService/HelloWorld. 

at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() 

at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) 

at System.Web.Services.Protocols.SoapServerProtocol.Initialize() 

at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)' faultactor: 'null' detail: [email protected] 

Trả lời

0

sử dụng SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

thay vì

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
    SoapEnvelope.VER12); 

và loại bỏ dòng này androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

và thay vì SoapObject response = (SoapObject)envelope.getResponse();

sử dụng SoapObject response = (SoapObject)envelope.bodyIn;

nó sẽ giúp you.If vẫn nhận được lỗi sau đó Viết tôi.

Các vấn đề liên quan