Foros del Web » Programando para Internet » ASP Clásico »

Cliente WS-SOAP sobre HTTPS

Estas en el tema de Cliente WS-SOAP sobre HTTPS en el foro de ASP Clásico en Foros del Web. Buenas a todos, A ver si alguien puede echarme una ayudita con un WebService con el que no consigo llevarme bien. Os pongo en antecendes: ...
  #1 (permalink)  
Antiguo 14/08/2012, 09:41
 
Fecha de Ingreso: marzo-2011
Ubicación: Barcelona
Mensajes: 9
Antigüedad: 13 años, 1 mes
Puntos: 1
Cliente WS-SOAP sobre HTTPS

Buenas a todos,

A ver si alguien puede echarme una ayudita con un WebService con el que no consigo llevarme bien. Os pongo en antecendes:

Necesitamos conectarnos a un WebService del Ministerio de Fomento, el cual está desarrollado sobre un protocolo HTTPS. La solicitud del acceso al servicio se realizan mediante formularios, y para garantizar la confidencialidad se usa comunicación SSL, además de un filtrado por IP y una autenticación mediante un certificado digital.

Mi problema es que no tengo mucha idea de como realizar un cliente de SOAP desde ASP normal, pero he estado buscando por internet y he encontrado información que me ha ayudado a comenzar. He conseguido registrar el certificado con el usuario IWAM, por lo que ya tengo acceso al WebService con conexiones del tipo GET. El problema lo tengo cuando intento realizar un POST de un SOAP en formato XML. El servidor me devuelve error, y aunque he preguntado en el Ministerio, no han podido ayudarme demasiado.

Os pongo mi código para que veáis como hago la llamada y el error que he consegudio capturar:

Código:
        
Set xmlhttp = Server.createobject("MSXML2.ServerXMLHTTP.3.0")
xmlhttp.setOption(3) = "LOCAL_MACHINE\My\ENTIDAD XXXXXXX - CIF XXXXXX - NOMBRE XXXXXXXXX" 
	
xmlhttp.Open "POST", strURL, false
xmlhttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
xmlhttp.setRequestHeader "action", strSOAPAction
xmlhttp.setRequestHeader "SOAPAction", strSOAPAction

' Aquí devuelve el error: strSOAP contiene el XML
xmlhttp.send strSoap
El error que me devuelve es este:
http://www.w3.org/2005/08/addressing/soap/faults:Sendera:BadContextTokenThe security context token is expired or is not valid. The message was not processed.
Haciendo pruebas, creo que el problema lo tengo a montar el XML. Os lo anoto también:

Código HTML:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://ServicioBonificacion.Model/2012/ServicioBonificacion">
<soap:Header/>
<soap:Body>
<ser:ServicioBonificacion>
<ser:ServicioBonificacionEntrada>
<ser:DatosSolicitante>
<ser:NumDoc>12345678A</ser:NumDoc>
<ser:TipoDoc>DNI</ser:TipoDoc>
<ser:Nombre>XXXXX</ser:Nombre>
<ser:Apellido1>XXXXXXX</ser:Apellido1>
<ser:Apellido2>XXXXXX</ser:Apellido2>
</ser:DatosSolicitante>
<ser:DatosViaje>
<ser:Origen>XXXXXXXX</ser:Origen>
<ser:Destino>XXXXXXX</ser:Destino>
</ser:DatosViaje>
<ser:ModoTransporte>2</ser:ModoTransporte>
<ser:CodigoBillete>20120726_1512</ser:CodigoBillete>
</ser:ServicioBonificacionEntrada>
<ser:ServicioBonificacionSalida>
<ser:CodigoRespuesta>
</ser:CodigoRespuesta>
<ser:DescripcionRespuesta></ser:DescripcionRespuesta>
<ser:CodigoVerificacion></ser:CodigoVerificacion>
</ser:ServicioBonificacionSalida>
</ser:ServicioBonificacion>
</soap:Body>
</soap:Envelope> 

A ver si alguien me puede echar un cable. Porqué ya no sé por donde seguir!!!

Muchas Gracias a todos de antemano!!

Saludos.
  #2 (permalink)  
Antiguo 14/08/2012, 09:42
 
Fecha de Ingreso: marzo-2011
Ubicación: Barcelona
Mensajes: 9
Antigüedad: 13 años, 1 mes
Puntos: 1
Respuesta: Cliente WS-SOAP sobre HTTPS

Por cierto, os indico también el WSDL:

Código HTML:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="WCFServicioBonificacion" targetNamespace="http://ServicioBonificacion.Model/2012/ServicioBonificacion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://ServicioBonificacion.Model/2012/ServicioBonificacion" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
  <wsp:Policy wsu:Id="EP_BasicHTTP_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <sp:TransportToken>
              <wsp:Policy>
                <sp:HttpsToken RequireClientCertificate="false"/>
              </wsp:Policy>
            </sp:TransportToken>
            <sp:AlgorithmSuite>
              <wsp:Policy>
                <sp:Basic256/>
              </wsp:Policy>
            </sp:AlgorithmSuite>
            <sp:Layout>
              <wsp:Policy>
                <sp:Strict/>
              </wsp:Policy>
            </sp:Layout>
            <sp:IncludeTimestamp/>
          </wsp:Policy>
        </sp:TransportBinding>
        <sp:EndorsingSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
              <wsp:Policy>
                <sp:BootstrapPolicy>
                  <wsp:Policy>
                    <sp:SignedParts>
                      <sp:Body/>
                      <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
                      <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
                      <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                      <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                      <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
                      <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                      <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
                    </sp:SignedParts>
                    <sp:EncryptedParts>
                      <sp:Body/>
                    </sp:EncryptedParts>
                    <sp:TransportBinding>
                      <wsp:Policy>
                        <sp:TransportToken>
                          <wsp:Policy>
                            <sp:HttpsToken RequireClientCertificate="false"/>
                          </wsp:Policy>
                        </sp:TransportToken>
                        <sp:AlgorithmSuite>
                          <wsp:Policy>
                            <sp:Basic256/>
                          </wsp:Policy>
                        </sp:AlgorithmSuite>
                        <sp:Layout>
                          <wsp:Policy>
                            <sp:Strict/>
                          </wsp:Policy>
                        </sp:Layout>
                        <sp:IncludeTimestamp/>
                      </wsp:Policy>
                    </sp:TransportBinding>
                    <sp:EndorsingSupportingTokens>
                      <wsp:Policy>
                        <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                          <wsp:Policy>
                            <sp:RequireThumbprintReference/>
                            <sp:WssX509V3Token10/>
                          </wsp:Policy>
                        </sp:X509Token>
                        <sp:SignedParts>
                          <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
                        </sp:SignedParts>
                      </wsp:Policy>
                    </sp:EndorsingSupportingTokens>
                    <sp:Wss11>
                      <wsp:Policy>
                        <sp:MustSupportRefThumbprint/>
                      </wsp:Policy>
                    </sp:Wss11>
                    <sp:Trust10>
                      <wsp:Policy>
                        <sp:MustSupportIssuedTokens/>
                        <sp:RequireClientEntropy/>
                        <sp:RequireServerEntropy/>
                      </wsp:Policy>
                    </sp:Trust10>
                  </wsp:Policy>
                </sp:BootstrapPolicy>
              </wsp:Policy>
            </sp:SecureConversationToken>
          </wsp:Policy>
        </sp:EndorsingSupportingTokens>
        <sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy/>
        </sp:Wss11>
        <sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <sp:MustSupportIssuedTokens/>
            <sp:RequireClientEntropy/>
            <sp:RequireServerEntropy/>
          </wsp:Policy>
        </sp:Trust10>
        <wsaw:UsingAddressing/>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xsd:schema targetNamespace="http://ServicioBonificacion.Model/2012/ServicioBonificacion/Imports">
      <xsd:import schemaLocation="https://prebonificaciontransporte.fomento.gob.es/EMFOM.ServicioBonificacion.WS/WCFServicioBonificacion.svc?xsd=xsd1" namespace="http://ServicioBonificacion.Model/2012/ServicioBonificacion"/>
      <xsd:import schemaLocation="https://prebonificaciontransporte.fomento.gob.es/EMFOM.ServicioBonificacion.WS/WCFServicioBonificacion.svc?xsd=xsd2" namespace="http://ServicioBonificacion.Model/2012/ServiceBonificacionFaultMessaje"/>
      <xsd:import schemaLocation="https://prebonificaciontransporte.fomento.gob.es/EMFOM.ServicioBonificacion.WS/WCFServicioBonificacion.svc?xsd=xsd0" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="MessageRequest">
    <wsdl:part name="ServicioBonificacion" element="tns:ServicioBonificacion"/>
  </wsdl:message>
  <wsdl:message name="MessageResponse">
    <wsdl:part name="ServicioBonificacion" element="tns:ServicioBonificacion"/>
  </wsdl:message>
  <wsdl:message name="ServicioBonificacionServiceContract_CompruebaBonificacion_ServicioBonificacionFaultMessajeFault_FaultMessage">
    <wsdl:part name="detail" element="q1:ServicioBonificacionFaultMessaje" xmlns:q1="http://ServicioBonificacion.Model/2012/ServiceBonificacionFaultMessaje"/>
  </wsdl:message>
  <wsdl:portType name="ServicioBonificacionServiceContract">
    <wsdl:operation name="CompruebaBonificacion">
      <wsdl:input wsaw:Action="http://ServicioBonificacion.Model/2012/ServicioBonificacion/ServicioBonificacionServiceContract/CompruebaBonificacion" name="MessageRequest" message="tns:MessageRequest"/>
      <wsdl:output wsaw:Action="http://ServicioBonificacion.Model/2012/ServicioBonificacion/ServicioBonificacionServiceContract/CompruebaBonificacionResponse" name="MessageResponse" message="tns:MessageResponse"/>
      <wsdl:fault wsaw:Action="http://ServicioBonificacion.Model/2012/ServicioBonificacion/ServicioBonificacionServiceContract/CompruebaBonificacionServicioBonificacionFaultMessajeFault" name="ServicioBonificacionFaultMessajeFault" message="tns:ServicioBonificacionServiceContract_CompruebaBonificacion_ServicioBonificacionFaultMessajeFault_FaultMessage"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="EP_BasicHTTP" type="tns:ServicioBonificacionServiceContract">
    <wsp:PolicyReference URI="#EP_BasicHTTP_policy"/>
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="CompruebaBonificacion">
      <soap12:operation soapAction="http://ServicioBonificacion.Model/2012/ServicioBonificacion/ServicioBonificacionServiceContract/CompruebaBonificacion" style="document"/>
      <wsdl:input name="MessageRequest">
        <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="MessageResponse">
        <soap12:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="ServicioBonificacionFaultMessajeFault">
        <soap12:fault name="ServicioBonificacionFaultMessajeFault" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="WCFServicioBonificacion">
    <wsdl:port name="EP_BasicHTTP" binding="tns:EP_BasicHTTP">
      <soap12:address location="https://prebonificaciontransporte.fomento.gob.es/EMFOM.ServicioBonificacion.WS/WCFServicioBonificacion.svc"/>
      <wsa10:EndpointReference>
        <wsa10:Address>https://prebonificaciontransporte.fomento.gob.es/EMFOM.ServicioBonificacion.WS/WCFServicioBonificacion.svc</wsa10:Address>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions> 
Muchas Gracias.
  #3 (permalink)  
Antiguo 09/10/2012, 05:23
 
Fecha de Ingreso: octubre-2012
Mensajes: 1
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Cliente WS-SOAP sobre HTTPS

Hola

tengo exactamente el mismo problema que tu al intentar consumir los mismo WS. ¿tienes alguna solucion? He preguntado a Fomento a ver si saben algo.

Saludos

Etiquetas: asp, cliente, https, server
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:26.