2009-09-02 17 views
5

Sto riscontrando alcuni problemi importanti nel tentativo di utilizzare il servizio web PHP SOAP utilizzando ASP.NET. Il webservice in questione si basa su l'estensione PHP SOAP ed è descibed dal seguente WSDL:Consumo di un servizio Web SOAP PHP con ASP.NET

<?xml version="1.0" encoding="UTF-8" ?> 
<definitions name="MyServices" 
    targetNamespace="http://mydomain.com/api/soap/v11/services" 
    xmlns:tns="http://mydomain.com/api/soap/v11/services" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsd1="http://mydomain.com/api/soap/v11/services" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/"> 

<types> 
    <schema targetNamespace="http://mydomain.com/api/soap/v11/services" xmlns="http://www.w3.org/2001/XMLSchema"> 
     <complexType name="ServiceType"> 
      <all> 
       <element name="id" type="xsd:int" minOccurs="1" maxOccurs="1" /> 
       <element name="name" type="xsd:string" minOccurs="1" maxOccurs="1" /> 
       <element name="cost" type="xsd:float" minOccurs="1" maxOccurs="1" /> 
      </all> 
     </complexType> 
     <complexType name="ArrayOfServiceType"> 
      <all> 
       <element name="Services" type="ServiceType" minOccurs="0" maxOccurs="unbounded" /> 
      </all> 
     </complexType> 
    </schema> 
</types> 


<message name="getServicesRequest"> 
    <part name="postcode" type="xsd:string" /> 
</message> 

<message name="getServicesResponse"> 
    <part name="Result" type="xsd1:ArrayOfServiceType"/> 
</message> 

<portType name="ServicesPortType"> 
    <operation name="getServices"> 
    <input message="tns:getServicesRequest"/> 
    <output message="tns:getServicesResponse"/> 
    </operation> 
</portType> 

<binding name="ServicesBinding" type="tns:ServicesPortType"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <operation name="getServices"> 
    <soap:operation soapAction="http://mydomain.com/api/soap/v11/services/getServices" /> 
    <input> 
     <soap:body use="encoded" namespace="urn:my:services" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> 
    </input> 
    <output> 
     <soap:body use="encoded" namespace="urn:my:services" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> 
    </output> 
    </operation> 
</binding> 

<service name="MyServices"> 
    <port name="ServicesPort" binding="tns:ServicesBinding"> 
    <soap:address location="http://mydomain.com/api/soap/v11/services"/> 
    </port> 
</service> 
</definitions> 

posso generare con successo una classe proxy da questo WSDL in Visual Studio, ma al momento cercando di richiamare il metodo getServices Sono presentato con un'eccezione:

System.Web.Services.Protocols.SoapHeaderException: procedura 'stringa' non presentare

Dopo aver ispezionato i dati post prime a fine server SOAP, il mio cliente PHP SOAP sta facendo richieste così:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
     <postcode xsi:type="xsd:string">ln4 4nq</postcode> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

considerando che la classe proxy .Net sta facendo questo:

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:tns="http://mydomain.com/api/soap/v11/services" 
    xmlns:types="http://mydomain.com/api/soap/v11/services/encodedTypes" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
     <xsd:string xsi:type="xsd:string">LN4 4NQ</xsd:string> 
    </soap:Body> 
</soap:Envelope> 

posso solo supporre la differenza nel modo in cui il parametro di Cap è stato inviato è dove sta il problema, ma in primo luogo come uno sviluppatore PHP Sono in perdita per ciò che sta accadendo qui. Ho la sensazione che mi manchi semplicemente qualcosa di vitale nel mio WSDL visto che ho visto innumerevoli esempi di "Consumare servizi web SOAP PHP con .Net" che sembrano suggerire che funziona ".

Qualsiasi suggerimento su dove sono scivolato qui sarebbe molto apprezzato. Ho attualmente trascorso quasi un giorno intero su questo ora ;-)

Grazie in anticipo,

Jamie

+0

È facile scivolare ... su SOAP :-D – andychase

risposta

1

dispiace per rendere una risposta anziché un commento di Io non hanno abbastanza reputazione per che ...

Dovresti provare a testare il tuo webservice con SOAP-UI (hanno una versione gratuita), così saprai se il problema è lato client o lato server.

0

Il WSDL ha errori, quindi molto probabilmente la classe proxy è corrotta. Quindi è la richiesta.
WSDL è molto complesso da fare a meno che non si usi un buon editor WSDL. Vorrei suggerire l'editor di Eclipse WSDL (http://wiki.eclipse.org/index.php/Introduction_to_the_WSDL_Editor)

(1) Il {max occorrenza} di un elemento in un gruppo di modelli "tutti" deve essere 0 o 1. Il valore "-1" per l'elemento "Servizi" non è valido.
(2) Errore durante la risoluzione del componente 'ServiceType'. È stato rilevato che 'ServiceType' è nello spazio nomi 'http://www.w3.org/2001/XMLSchema', ma i componenti di questo spazio dei nomi non sono referenziabili dal documento dello schema

Problemi correlati