2014-05-22 19 views
6

Ho creato un servizio Web ASP.NET (asmx) per consentire a software di terze parti di connettersi alla mia soluzione. Il webservice funziona bene quando viene chiamato utilizzando SOAP 1.1 o tramite il modulo di chiamata di ASP.NET quando viene chiamato dal server su cui risiede.SOAP 1.2 restituisce una cattiva richiesta mentre SOAP 1.1 funziona

Quindi qual è il problema, la parte di connessione supporta solo SOAP 1.2, quando chiama il servizio web utilizzando SOAP 1.2 restituisce 400 Cattiva richiesta.

Ho permesso SOAP 1.2 nel web.config:

<configuration> 
    <system.web> 
     <webServices> 
      <soapExtensionTypes> 
       <add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0" /> 
      </soapExtensionTypes> 
      <protocols> 
       <add name="HttpSoap12" /> 
       <add name="HttpGet" /> 
       <add name="HttpPost" /> 
      </protocols> 
     </webServices> 
    </system.web> 
</configuration> 

Io uso l'estensione per un'altra parte, ho cercato di disabilitare tramite configurazione specifico posizione, ma che non ha dato risultati. tracing

Ho permesso:

<system.diagnostics> 
    <trace autoflush="true" /> 
    <sources> 
     <source name="System.Web.Services.Asmx"> 
      <listeners> 
       <add name="AsmxTraceFile" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:\Trace.log" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId" /> 
      </listeners> 
     </source> 
    </sources> 
    <switches> 
     <add name="System.Web.Services.Asmx" value="Verbose" /> 
    </switches> 
</system.diagnostics> 

Utilizzo del client Chrome avanzato Resto mando la seguente richiesta:

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Body> 
    <authenticateUser xmlns="http://services.kvh.nl/foo"> 
     <username>kvh</username> 
     <password></password> 
    </authenticateUser> 
    </soap12:Body> 
</soap12:Envelope> 

che si traduce in un 400 Richiesta e la seguente voce nel registro di traccia :

System.Web.Services.Asmx Information: 0 : Calling IHttpHandlerFactory.GetHandler 
    Caller: System.Web.Services.Protocols.WebServiceHandlerFactory#6565889::GetHandler() 
    Request Host Address: 10.1.1.8 
    Request Host Name: lb03.kvh.local 
    Request Url: [POST] http://services.kvh.nl/Services/MyWebservice.asmx 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.1166408Z 
    Timestamp=9623920014337 
System.Web.Services.Asmx Information: 0 : Calling XmlSerializer [Create XmlSerializer] 
    Method: System.Xml.Serialization.XmlSerializer#1912278872::FromMappings(System.Xml.Serialization.XmlMapping[]#40573663=[24], System.Security.Policy.Evidence#667347099=..) 
    Caller: System.Web.Services.Protocols.SoapServerType#31148249::.ctor(WWW.Services.MyWebservice#477438864=WWW.Services.MyWebservice, System.Web.Services.Configuration.WebServiceProtocols#63=HttpGet, HttpPost, Documentation, HttpPostLocalhost, AnyHttpSoap) 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.1478409Z 
    Timestamp=9623920106472 
System.Web.Services.Asmx Information: 0 : Return from XmlSerializer [Create XmlSerializer] 
    Caller: System.Web.Services.Protocols.SoapServerType#31148249::.ctor(WWW.Services.MyWebservice#477438864=WWW.Services.MyWebservice, System.Web.Services.Configuration.WebServiceProtocols#63=HttpGet, HttpPost, Documentation, HttpPostLocalhost, AnyHttpSoap) 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.3038412Z 
    Timestamp=9623920433863 
System.Web.Services.Asmx Information: 0 : Calling SoapExtension 
    Method: Microsoft.Web.Services2.WebServicesExtension#3391963::ProcessMessage(System.Web.Services.Protocols.SoapMessageStage#4=BeforeDeserialize) 
    Caller: System.Web.Services.Protocols.SoapServerMessage#31258077::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#34069029=[1], System.Boolean#0=False) 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.3038412Z 
    Timestamp=9623920435703 
System.Web.Services.Asmx Information: 0 : Return from SoapExtension 
    Caller: System.Web.Services.Protocols.SoapServerMessage#31258077::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#34069029=[1], System.Boolean#0=False) 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.3506412Z 
    Timestamp=9623920542168 
System.Web.Services.Asmx Warning: 0 : Exception caught in System.Web.Services.Protocols.SoapServerProtocolFactory#48477748::Create. 
    System.Xml.XmlException: Root element is missing. 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.3506412Z 
    Timestamp=9623920545216 
System.Web.Services.Asmx Warning: 0 : Exception Details: 
System.Xml.XmlException: Root element is missing. 
    at System.Xml.XmlTextReaderImpl.Throw(Exception e) 
    at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) 
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent() 
    at System.Xml.XmlTextReaderImpl.Read() 
    at System.Xml.XmlTextReader.Read() 
    at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read() 
    at System.Xml.XmlReader.MoveToContent() 
    at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent() 
    at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() 
    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.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) 
    at System.Web.Servic... 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.3506412Z 
    Timestamp=9623920548659 
System.Web.Services.Asmx Error: 0 : Exception thrown in System.Web.Services.Protocols.WebServiceHandlerFactory#6565889::CoreGetHandler(). 
    System.InvalidOperationException: Failed to handle request. 
    ProcessId=11272 
    LogicalOperationStack= 
    ThreadId=6 
    DateTime=2014-05-22T13:28:45.3506412Z 
    Timestamp=9623920549597 

googled a quasi follia, ma purtroppo non sono stato abl e per trovare una soluzione.

Qualsiasi aiuto è molto apprezzato.

EDIT:

Purtroppo il suggerimento di rAhuID te rimuovere il supporto SOAP 1.1 questo non ha risolto il problema. Sono andato avanti e ho provato un po 'più di opzioni come cancellare tutti i protocolli e aggiungere solo HttpSoap12 e Documentation che sembra peggiorare le cose. Ho quindi rimosso tutti i protocolli che non sono necessari. L'XmlException è scomparso dai log ma ho ancora una 400 Bad request :(

Ho provato dal computer locale (utilizzando il file hosts in modo da poter usare il nome host corretto) per escludere il server proxy come problema .

web.config currrent:

<protocols> 
    <!-- 
     <clear /> 
     <add name="Documentation" /> 
     <add name="HttpSoap12" /> 
    --> 
    <remove name="HttpGet" /> 
    <remove name="HttpPost" /> 
    <remove name="HttpPostLocalhost" /> 
    <remove name="HttpSoap" /> 
</protocols> 

Diagnostica:.

System.Web.Services.Asmx Information: 0 : Calling IHttpHandlerFactory.GetHandler 
    Caller: System.Web.Services.Protocols.WebServiceHandlerFactory#31931339::GetHandler() 
    Request Host Address: 127.0.0.1 
    Request Host Name: web01.kvh.nl 
    Request Url: [POST] http://services.kvh.nl/services/MyWebservice.asmx 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:39.7977582Z 
    Timestamp=9802327858068 
System.Web.Services.Asmx Information: 0 : Calling XmlSerializer [Create XmlSerializer] 
    Method: System.Xml.Serialization.XmlSerializer#1912278872::FromMappings(System.Xml.Serialization.XmlMapping[]#53221370=[24], System.Security.Policy.Evidence#656725186=..) 
    Caller: System.Web.Services.Protocols.SoapServerType#63548859::.ctor(WWW.Services.MyWebservice#445910576=WWW.Services.MyWebservice, System.Web.Services.Configuration.WebServiceProtocols#40=Documentation, HttpSoap12) 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:39.8445582Z 
    Timestamp=9802327942578 
System.Web.Services.Asmx Information: 0 : Return from XmlSerializer [Create XmlSerializer] 
    Caller: System.Web.Services.Protocols.SoapServerType#63548859::.ctor(WWW.Services.MyWebservice#445910576=WWW.Services.MyWebservice, System.Web.Services.Configuration.WebServiceProtocols#40=Documentation, HttpSoap12) 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:39.9849585Z 
    Timestamp=9802328272841 
System.Web.Services.Asmx Information: 0 : Calling SoapExtension 
    Method: Microsoft.Web.Services2.WebServicesExtension#59584177::ProcessMessage(System.Web.Services.Protocols.SoapMessageStage#4=BeforeDeserialize) 
    Caller: System.Web.Services.Protocols.SoapServerMessage#64042303::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#63331368=[1], System.Boolean#0=False) 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:39.9849585Z 
    Timestamp=9802328273636 
System.Web.Services.Asmx Information: 0 : Return from SoapExtension 
    Caller: System.Web.Services.Protocols.SoapServerMessage#64042303::RunExtensions(System.Web.Services.Protocols.SoapExtension[]#63331368=[1], System.Boolean#0=False) 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:39.9849585Z 
    Timestamp=9802328287199 
System.Web.Services.Asmx Information: 0 : Calling RouteRequest 
    Method: System.Web.Services.Protocols.SoapServerType#63548859::GetMethod(System.String#768149269="http://services.kvh.nl/foo/authenticateUser") 
    Caller: System.Web.Services.Protocols.Soap12ServerProtocolHelper#31339276::RouteRequest() 
    Request Host Address: 127.0.0.1 
    Request Host Name: web01.kvh.nl 
    Request Url: [POST] http://services.kvh.nl/services/MyWebservice.asmx 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:40.0005585Z 
    Timestamp=9802328288057 
System.Web.Services.Asmx Information: 0 : Return from RouteRequest 
    Caller: System.Web.Services.Protocols.Soap12ServerProtocolHelper#31339276::RouteRequest() 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:40.0005585Z 
    Timestamp=9802328288265 
System.Web.Services.Asmx Information: 0 : Return from IHttpHandlerFactory.GetHandler 
    Caller: System.Web.Services.Protocols.WebServiceHandlerFactory#31931339::GetHandler() 
    ProcessId=15596 
    LogicalOperationStack= 
    ThreadId=10 
    DateTime=2014-05-23T11:13:40.0005585Z 
    Timestamp=9802328288464 
+0

Grazie mille, mi hai appena salvato un sacco di frustrazione! – mrexodia

risposta

1

Grazie mille per il vostro aiuto.

Ho creato un piccolo sito Web di test e ho scoperto che SOAP 1.2 funzionava con la configurazione predefinita. Ho aggiunto gadgetosamente la configurazione con l'obiettivo di rispecchiare la configurazione reale.

In questo modo ho trovato che l'estensione SOAP ha causato il problema. Se si verificano gli stessi problemi, è possibile abilitare l'estensione per una posizione specifica, ma impossibile da disabilitare per una posizione specifica.

L'(di lavoro) configurazione risultante è la seguente:

<configuration> 
    <system.web> 
     <webServices> 
      <protocols> 
       <add name="HttpGet" /> 
       <add name="HttpPost" /> 
      </protocols> 
     </webServices> 
    </system.web> 
    <location path="Services/MyOtherWebservice.asmx"> 
     <system.web> 
      <webServices> 
       <soapExtensionTypes> 
        <add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="0" /> 
       </soapExtensionTypes> 
      </webServices> 
     </system.web> 
    </location> 
</configuration> 

Grazie per il vostro aiuto molto apprezzato!

1

Prova a specificare "AnyHttpSoap" invece di "HttpSoap12"

O come hai detto, se supportano solo 1.2, invece di aggiungere "HttpSoap12", basta rimuovere "HttpSoap" dal protocollo.

<protocols> 
    <remove name="HttpSoap"/> 
</protocols> 

This potrebbe aiutare.

+0

Grazie per la tua risposta, sfortunatamente il problema non è stato risolto con questo metodo, ho modificato la domanda con un input aggiuntivo basato sulla tua risposta. – KvH

0

lato client deve specificare Azione in una sezione di intestazione, questo è come si fa in PHP ("questo" è un SoapClient)

$headers = array(); 
$headers[] = $this->generateWSSecurityHeader(); 
$headers[] = new SoapHeader('http://www.w3.org/2005/08/addressing', 'Action', $actionService . $function_name, false);   
$this->__setSoapHeaders($headers); 

Richiesta XML:

<?xml version="1.0"?> 
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/" xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns3="http://www.w3.org/2005/08/addressing"> 
    <env:Header> 
     <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" env:mustUnderstand="true"> 
      <wsse:UsernameToken wsu:Id="UsernameToken-2"> 
       <wsse:Username>someusername</wsse:Username> 
       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">123456</wsse:Password> 
       <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">ffe276c004cfca769fcd90d719037bf7f3b182a1</wsse:Nonce> 
      </wsse:UsernameToken> 
     </wsse:Security> 
     <ns3:Action>http://tempuri.org/IBusXmlService/FindBusStops</ns3:Action> 
    </env:Header> 
    <env:Body> 
     <ns1:FindBusStops/> 
    </env:Body> 
</env:Envelope> 

Spero che questo aiuti