none
calling web service using basicHttpBinding from classic asp file RRS feed

  • Question

  • I have a WCF web service that connects to most applications using wsHttpBinding.  I have to connect to this web service from a classic asp file.  From what I have read and tried, I need to use basicHttpBinding to do this.  It is SOAP 1.1 and to use webhttpbinding, I would have to change the web service interface by adding `[WebGet]` and this is not an option. So I added the basicHttpBinding to the web service. 

    I run the asp file using a console application. When it is run, I get the error:

     The message with  Action 'urn:http://tempuri.org/IPaging/TestMethod'
     cannot be processed at the receiver,  due to a ContractFilter mismatch
     at the EndpointDispatcher.  This may be because of either a contract
     mismatch (mismatched Actions between sender and receiver)  or a
     binding/security mismatch between the sender and the receiver.   Check
     that sender and receiver have the same contract and the  same binding
     (including security requirements, e.g. Message, Transport, None).

    I don't see where I am going wrong.  I have the URL set to call the basic binding.  The SOAP message is using 1.1 and I believe it is correct.

    Why is there a mismatch between the sender and receiver?  
    There is no app.config file on the client side to define the connection.  It is just 1 asp file.  If I need that, how does the asp file read the app.config file?

    Config file below:

    <system.serviceModel>
        <services>
          <service name="PagingService.Paging" behaviorConfiguration="SimpleServiceBehavior">
        	<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPaging" contract="PagingService.IPaging">
        	  <identity>
        		<dns value="localhost"/>
        	  </identity>
        	</endpoint>
        	<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPaging" contract="PagingService.IPaging">
        	</endpoint>
        	<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        	<host>
        	  <baseAddresses>
        		<add baseAddress="http://localhost:8732/Design_Time_Addresses/PagingService/Service1/"/>
        	  </baseAddresses>
        	</host>
          </service>
        </services>
        <bindings>
          <wsHttpBinding>
        	<binding name="WSHttpBinding_IPaging" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" sendTimeout="00:25:00">
        	  <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        	</binding>
          </wsHttpBinding>
          <basicHttpBinding>
        	<binding name="BasicHttpBinding_IPaging">
        	  <security mode="None"></security>
        	</binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
        	<behavior name="SimpleServiceBehavior">      
        	  <serviceMetadata httpGetEnabled="True"/>      
        	  <serviceDebug includeExceptionDetailInFaults="False"/>
        	</behavior>
          </serviceBehaviors>
        </behaviors>
        </system.serviceModel>

    I want to call the method `TestMethod` from the paging service from the classic asp file
    This is the WSDL that describes the TestMethod:

    <wsdl:operation name="TestMethod">
              <wsdl:input wsaw:Action="http://tempuri.org/IPaging/TestMethod" message="tns:IPaging_TestMethod_InputMessage" /> 
              <wsdl:output wsaw:Action="http://tempuri.org/IPaging/TestMethodResponse" message="tns:IPaging_TestMethod_OutputMessage" /> 
        </wsdl:operation>
        
        <wsdl:operation name="TestMethod">
          <soap:operation soapAction="http://tempuri.org/IPaging/TestMethod" style="document" /> 
        - <wsdl:input>
          <soap:body use="literal" /> 
          </wsdl:input>
        - <wsdl:output>
          <soap:body use="literal" /> 
          </wsdl:output>
          </wsdl:operation>
    
    This is how the basicHttpBinding is defined in the WSDL:

     <wsdl:port name="BasicHttpBinding_IPaging" binding="tns:BasicHttpBinding_IPaging">
        <soap:address location="http://<server>:<port>/Fld1/PagingService.Paging.svc/basic" /> 
        </wsdl:port>
    This is the asp code that calls the web service:
    Dim NS, NS_SOAP, NS_SOAPENC, NS_XSI, NS_XSD
        NS = "urn:http://tempuri.org/"
        NS_SOAP = "http://schemas.xmlsoap.org/soap/envelope/"
        NS_SOAPENC = "http://schemas.xmlsoap.org/soap/encoding"
        NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
        NS_XSD = "http://www.w3.org/2001/XMLSchema"
        
        'Using basicHttpBinding
        URL = "http://<server><port>/Fld1/PagingService.Paging.svc/basic"
        
        ' XML DOM objects.
        Dim DOM, Envelope, Body, Operation, Param 
        
        ' Creates an XML DOM object.
        Set objXmlDoc = CreateObject("MSXML2.DOMDocument.6.0") 
        objXmlDoc.async = false
        
        Set Envelope = objXmlDoc.createNode(1, "soap:Envelope", NS_SOAP)
        Envelope.setAttribute "xmlns:soapenc", NS_SOAPENC
        Envelope.setAttribute "xmlns:xsi", NS_XSI
        Envelope.setAttribute "xmlns:xsd", NS_XSD
        objXmlDoc.appendChild Envelope
        Set Body = objXmlDoc.createNode(1, "Body", "http://schemas.xmlsoap.org/soap/envelope/")
        Envelope.appendChild Body 
        Set Operation = objXmlDoc.createNode(1, "TestMethod", NS)
        Body.appendChild Operation 
        
        Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
        httpRequest.Open "POST", URL, False    
        httpRequest.setRequestHeader "Content-Type", "text/xml"  
        httpRequest.setRequestHeader "SOAPAction", "urn:http://tempuri.org/IPaging/TestMethod"
        httpRequest.send objXmlDoc.xml
        
        strStatusText = "Status: " & httpRequest.status & vbCrLf & "Status text: " & httpRequest.statusText
        Response.Write(vbCrLf & strStatusText & vbCrLf)  
        Response.Write(httpRequest.responseText)
        
        Set Operation = Nothing
        Set Body = Nothing
        Set Envelope = Nothing

    Thanks.

    Thursday, March 10, 2016 5:17 PM

Answers

  • I figured this out.

    In case anybody else gets a terrible job like this.  Here is how I solved it...

    Added the binding, basicHttpBinding.  This works with SOAP 1.1 which is the only version of SOAP that the ancient classic asp file that I had to use will connect to.

    Then creating the SOAP Envelope.  This needs to be exact.  At least in my case.

    Use the code above but there are 2 changes.

    Remove 'urn:' when defining the namespace constant.

    Where I defined the SOAPAction in the setRequestHeader, remove 'urn:'.

    So the NS constant will be this:

    NS = "http://tempuri.org/"

    The setRequestHeader for 'SOAPAction' looks like this:

    httpRequest.setRequestHeader "SOAPAction", "http://tempuri.org/IPaging/TestMethod"

    This called the method and returned the string from the method.

    Everything else in the above code was fine.

    • Marked as answer by Gloria10 Monday, March 21, 2016 1:35 PM
    Monday, March 21, 2016 1:35 PM

All replies

  • https://msdn.microsoft.com/en-us/library/bb735856.aspx?f=255&MSPPError=-2147217396#_Toc156817373

    You may have to go in the above direction. On the other hand, classic ASP is too old.

    Friday, March 11, 2016 1:21 AM
  • I figured this out.

    In case anybody else gets a terrible job like this.  Here is how I solved it...

    Added the binding, basicHttpBinding.  This works with SOAP 1.1 which is the only version of SOAP that the ancient classic asp file that I had to use will connect to.

    Then creating the SOAP Envelope.  This needs to be exact.  At least in my case.

    Use the code above but there are 2 changes.

    Remove 'urn:' when defining the namespace constant.

    Where I defined the SOAPAction in the setRequestHeader, remove 'urn:'.

    So the NS constant will be this:

    NS = "http://tempuri.org/"

    The setRequestHeader for 'SOAPAction' looks like this:

    httpRequest.setRequestHeader "SOAPAction", "http://tempuri.org/IPaging/TestMethod"

    This called the method and returned the string from the method.

    Everything else in the above code was fine.

    • Marked as answer by Gloria10 Monday, March 21, 2016 1:35 PM
    Monday, March 21, 2016 1:35 PM