我使用netbeans创建了一个soap web服务。现在我想用我的Android应用程序连接到它。 这是我的android方法:
public final static String SOAP_ACTION = "http://EntityPackage/verifyClient";
public final static String NAMESPACE = "http://EntityPackage/";
public final static String URL = "http://localhost:8080/WS/WS";
private boolean SendUserData(){
SoapObject request = new SoapObject(NAMESPACE, "verifyClient");
request.addProperty("user", Profile.username);
request.addProperty("pwd1", Profile.password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE transport = new HttpTransportSE(URL);
transport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject)envelope.bodyIn;
}
这是我的WSDL:
<definitions targetNamespace="http://EntityPackage/" name="WS"><types><xsd:schema><xsd:import namespace="http://EntityPackage/" schemaLocation="http://localhost:8080/WS/WS?xsd=1"/></xsd:schema></types><message name="persist"><part name="parameters" element="tns:persist"/></message><message name="getPrenotazioniByAgenzia"><part name="parameters" element="tns:getPrenotazioniByAgenzia"/></message><message name="getPrenotazioniByAgenziaResponse"><part name="parameters" element="tns:getPrenotazioniByAgenziaResponse"/></message><message name="verifyClient"><part name="parameters" element="tns:verifyClient"/></message><message name="verifyClientResponse"><part name="parameters" element="tns:verifyClientResponse"/></message><message name="getPrenotazioniByCliente"><part name="parameters" element="tns:getPrenotazioniByCliente"/></message><message name="getPrenotazioniByClienteResponse"><part name="parameters" element="tns:getPrenotazioniByClienteResponse"/></message><portType name="WS"><operation name="persist"><input wsam:Action="http://EntityPackage/WS/persist" message="tns:persist"/></operation><operation name="getPrenotazioniByAgenzia"><input wsam:Action="http://EntityPackage/WS/getPrenotazioniByAgenziaRequest" message="tns:getPrenotazioniByAgenzia"/><output wsam:Action="http://EntityPackage/WS/getPrenotazioniByAgenziaResponse" message="tns:getPrenotazioniByAgenziaResponse"/></operation><operation name="verifyClient"><input wsam:Action="http://EntityPackage/WS/verifyClientRequest" message="tns:verifyClient"/><output wsam:Action="http://EntityPackage/WS/verifyClientResponse" message="tns:verifyClientResponse"/></operation><operation name="getPrenotazioniByCliente"><input wsam:Action="http://EntityPackage/WS/getPrenotazioniByClienteRequest" message="tns:getPrenotazioniByCliente"/><output wsam:Action="http://EntityPackage/WS/getPrenotazioniByClienteResponse" message="tns:getPrenotazioniByClienteResponse"/></operation></portType><binding name="WSPortBinding" type="tns:WS"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><operation name="persist"><soap:operation soapAction=""/><input><soap:body use="literal"/></input></operation><operation name="getPrenotazioniByAgenzia"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="verifyClient"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="getPrenotazioniByCliente"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation></binding><service name="WS"><port name="WSPort" binding="tns:WSPortBinding"><soap:address location="http://localhost:8080/WS/WS"/></port></service></definitions>
结果始终为null。 是对的SOAP_ACTION; URL和NAMESPACE ????
答案 0 :(得分:0)
可以肯定的是,你必须下载软件SOAPui 然后,使用您的WSDL文件创建一个新项目。您将看到不同方法的列表 双击其中一个,它将打开一个窗口,您可以在其中轻松地向服务发送请求并查看服务器的答案。另外还有一个RAW选项卡,您可以在其中看到确切的SOAP_ACTION / NAMESPACE等! 这个软件实际上解决了我所有的问题