2011-05-16 43 views
0

我開發一個應用程序使用的Web服務,如何消費以下Web服務? http方法或ksoap2?我試過Ksoap2,似乎無法正確提取此Web服務,任何人都可以幫助解決這個問題?提前致謝。如何飲用此WebService中的Android?

這裏是WSDL:http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl

是那個NAME_SPACE是:http://www.restfulwebservices.net/ServiceContracts/2008/01?方法是GetStockQuote?而SOAP_ACTION是GetStockQuote?

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions name="StockQuoteService" 
targetNamespace="http://www.restfulwebservices.net/ServiceContracts/2008/01" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 
xmlns:tns="http://www.restfulwebservices.net/ServiceContracts/2008/01" 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" 
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"> 
    <wsdl:types> 
    <xsd:schema targetNamespace="http://www.restfulwebservices.net/ServiceContracts/2008/01/Imports"> 

     <xsd:import schemaLocation="http://www.restfulwebservices.net/wcf/StockQuoteService.svc?xsd=xsd0" 
     namespace="http://www.restfulwebservices.net/ServiceContracts/2008/01" /> 
     <xsd:import schemaLocation="http://www.restfulwebservices.net/wcf/StockQuoteService.svc?xsd=xsd3" 
     namespace="http://GOTLServices.FaultContracts/2008/01" /> 
     <xsd:import schemaLocation="http://www.restfulwebservices.net/wcf/StockQuoteService.svc?xsd=xsd1" 
     namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
     <xsd:import schemaLocation="http://www.restfulwebservices.net/wcf/StockQuoteService.svc?xsd=xsd2" 
     namespace="http://www.restfulwebservices.net/DataContracts/2008/01" /> 
    </xsd:schema> 
    </wsdl:types> 
    <wsdl:message name="IStockQuoteService_GetStockQuote_InputMessage"> 

    <wsdl:part name="parameters" element="tns:GetStockQuote" /> 
    </wsdl:message> 
    <wsdl:message name="IStockQuoteService_GetStockQuote_OutputMessage"> 

    <wsdl:part name="parameters" 
    element="tns:GetStockQuoteResponse" /> 
    </wsdl:message> 
    <wsdl:message name="IStockQuoteService_GetStockQuote_DefaultFaultContractFault_FaultMessage"> 

    <wsdl:part name="detail" element="q1:DefaultFaultContract" 
    xmlns:q1="http://GOTLServices.FaultContracts/2008/01" /> 
    </wsdl:message> 
    <wsdl:message name="IStockQuoteService_GetWorldMajorIndices_InputMessage"> 

    <wsdl:part name="parameters" 
    element="tns:GetWorldMajorIndices" /> 
    </wsdl:message> 
    <wsdl:message name="IStockQuoteService_GetWorldMajorIndices_OutputMessage"> 

    <wsdl:part name="parameters" 
    element="tns:GetWorldMajorIndicesResponse" /> 
    </wsdl:message> 
    <wsdl:message name="IStockQuoteService_GetWorldMajorIndices_DefaultFaultContractFault_FaultMessage"> 

    <wsdl:part name="detail" element="q2:DefaultFaultContract" 
    xmlns:q2="http://GOTLServices.FaultContracts/2008/01" /> 
    </wsdl:message> 
    <wsdl:portType name="IStockQuoteService"> 
    <wsdl:operation name="GetStockQuote"> 
     <wsdl:input wsaw:Action="GetStockQuote" 
     message="tns:IStockQuoteService_GetStockQuote_InputMessage" /> 
     <wsdl:output wsaw:Action="http://www.restfulwebservices.net/ServiceContracts/2008/01/IStockQuoteService/GetStockQuoteResponse" 
     message="tns:IStockQuoteService_GetStockQuote_OutputMessage" /> 
     <wsdl:fault wsaw:Action="http://www.restfulwebservices.net/ServiceContracts/2008/01/IStockQuoteService/GetStockQuoteDefaultFaultContractFault" 
     name="DefaultFaultContractFault" 
     message="tns:IStockQuoteService_GetStockQuote_DefaultFaultContractFault_FaultMessage" /> 
    </wsdl:operation> 
    <wsdl:operation name="GetWorldMajorIndices"> 
     <wsdl:input wsaw:Action="GetWorldMajorIndices" 
     message="tns:IStockQuoteService_GetWorldMajorIndices_InputMessage" /> 
     <wsdl:output wsaw:Action="http://www.restfulwebservices.net/ServiceContracts/2008/01/IStockQuoteService/GetWorldMajorIndicesResponse" 
     message="tns:IStockQuoteService_GetWorldMajorIndices_OutputMessage" /> 
     <wsdl:fault wsaw:Action="http://www.restfulwebservices.net/ServiceContracts/2008/01/IStockQuoteService/GetWorldMajorIndicesDefaultFaultContractFault" 
     name="DefaultFaultContractFault" 
     message="tns:IStockQuoteService_GetWorldMajorIndices_DefaultFaultContractFault_FaultMessage" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="BasicHttpBinding_IStockQuoteService" 
    type="tns:IStockQuoteService"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="GetStockQuote"> 
     <soap:operation soapAction="GetStockQuote" 
     style="document" /> 
     <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
     <wsdl:fault name="DefaultFaultContractFault"> 
     <soap:fault name="DefaultFaultContractFault" 
     use="literal" /> 
     </wsdl:fault> 
    </wsdl:operation> 
    <wsdl:operation name="GetWorldMajorIndices"> 
     <soap:operation soapAction="GetWorldMajorIndices" 
     style="document" /> 
     <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
     <wsdl:fault name="DefaultFaultContractFault"> 
     <soap:fault name="DefaultFaultContractFault" 
     use="literal" /> 
     </wsdl:fault> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="StockQuoteService"> 
    <wsdl:port name="BasicHttpBinding_IStockQuoteService" 
    binding="tns:BasicHttpBinding_IStockQuoteService"> 
     <soap:address location="http://www.restfulwebservices.net/wcf/StockQuoteService.svc" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

這裏是requestDump:

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:d="http://www.w3.org/2001/XMLSchema" 
    xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"> 
     <v:Header /> 
     <v:Body> 
     <GetStockQuote xmlns="http://www.restfulwebservices.net/ServiceContracts/2008/01" 
     id="o0" c:root="1"> 
      <parameters i:type="d:string">IBM</parameters> 
     </GetStockQuote> 
     </v:Body> 
    </v:Envelope> 

responseDump:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
     <s:Body> 
     <s:Fault> 
      <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher"> 
      a:InternalServiceFault</faultcode> 
      <faultstring xml:lang="en-US">Object reference not set to an 
      instance of an object.</faultstring> 
      <detail> 
      <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" 
      xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
       <HelpLink i:nil="true" /> 
       <InnerException i:nil="true" /> 
       <Message>Object reference not set to an instance of an 
       object.</Message> 
       <StackTrace>at 
       GOTLServices.ServiceImplementation.StockQuoteService.GetStockQuote(String 
       symbol) 
    </StackTrace> 
      </ExceptionDetail> 
      </detail> 
     </s:Fault> 
     </s:Body> 
    </s:Envelope> 
+0

是否可以從SVC改變你的web服務ASMX並試圖通過ksoap2 libraray來使用它。設置SoapObject.Net =真 – Farhan 2011-05-16 08:13:19

+0

對不起@Farhan您的權利,但它像這些 'SoapSerializationEnvelope信封=新SoapSerializationEnvelope(SoapEnvelope.VER11); \t \t envelope.dotNet = TRUE;' – PedroAGSantos 2011-05-16 08:16:20

+0

檢查此鏈接:http://www.ibm.com/developerworks/webservices/library/ws-android/index.html – Farhan 2011-05-16 08:29:43

回答