Help required with SOAP call, getting error "ContractFilter mismatch at the EndpointDispatcher"

Hi all, hoping one of you Gurus can assist please.

I have been using a payment system for many years but they have now changed one of their SOAP calls to an external URL. For the life of me I'm unable to connect without the following error:

"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). "

these are the binding info from their App.config file if it helps
<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPortalService">
          <!-- Transport security is only required when the portal service is running under https, for http this should be set to None -->
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>

Open in new window


I'm using PHP7 and have free run on the server to implement any of your suggestions. Previously I used cURL to simply create the SOAP XML, post if off and grab the response but having no luck here.

I cant post all the login details etc as it's payment and site specific but I'm after being initially able to at least connect to the SOAP URL below, and get a more valid error (for example, invalid user logon) etc.

Ok, here's the details:

https://pay360sc.e-paycapita.com/LivePayments242/PortalService.svc?wsdl

Action required is "Invoke" for which I believe the following should be the right XML to be sent:

<invokeRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <credentials>
    <subject>
      <subjectType>SecureBureauServiceSite</subjectType>
      <identifier>242</identifier>
      <systemCode>APN</systemCode>
    </subject>
    <requestIdentification>
      <uniqueReference>3rdPartyRef48550</uniqueReference>
      <timeStamp>20181204085422</timeStamp>
    </requestIdentification>
    <signature>
      <algorithm>Original</algorithm>
      <hmacKeyID>1</hmacKeyID>
      <digest>6EpZzXc7JD1aq525LXySuybkTi+CdhUJuF023o3C+wM=</digest>
    </signature>
  </credentials>
  <login>
    <loginName>itsme</loginName>
    <password>anypassword</password>
    <consortiumCode>6Q</consortiumCode>
    <siteId>242</siteId>
  </login>
  <requestType>PayOnly</requestType>
  <requestId>036380e1-ed43-4cb0-af91-9d4fc81ced26</requestId>
  <sale>
    <items>
      <item>
        <itemDetails>
          <fundCode>02</fundCode>
          <reference>10948055</reference>
          <amountInMinorUnits>250</amountInMinorUnits>
        </itemDetails>
        <lineId>001</lineId>
      </item>
    </items>
  </sale>
</invokeRequest>

Open in new window


Happy to use SOAPClient or cURL, whatever you guys decide is best.
LVL 3
Neil ThompsonSenior Systems DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girionisCommented:
The XML you're sending is wrong, this is the correct one:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pay="http://www.capita-software.co.uk/software/pages/payments.aspx?apnPortal" xmlns:com="https://support.capita-software.co.uk/selfservice/?commonFoundation">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Invoke>
         <!--Optional:-->
         <tem:request>
            <!--Optional:-->
            <pay:credentials>
               <com:subject>
                  <com:subjectType>SecureBureauServiceSite</com:subjectType>
                  <com:identifier>242</com:identifier>
                  <!--Optional:-->
                  <com:systemCode>APN</com:systemCode>
               </com:subject>
               <com:requestIdentification>
                  <com:uniqueReference>3rdPartyRef48550</com:uniqueReference>
                  <com:timeStamp>20181204085422</com:timeStamp>
               </com:requestIdentification>
               <com:signature>
                  <com:algorithm>Original</com:algorithm>
                  <com:hmacKeyID>1</com:hmacKeyID>
                  <com:digest>6EpZzXc7JD1aq525LXySuybkTi+CdhUJuF023o3C+wM=</com:digest>
               </com:signature>
            </pay:credentials>
            <pay:login>
               <pay:loginName>itsme</pay:loginName>
               <pay:password>anypassword</pay:password>
               <pay:consortiumCode>6Q</pay:consortiumCode>
               <pay:siteId>242</pay:siteId>
            </pay:login>
            <pay:requestType>PayOnly</pay:requestType>
            <pay:requestId>036380e1-ed43-4cb0-af91-9d4fc81ced26</pay:requestId>
            <pay:routing/>
            <pay:sale>
               <pay:items>
                  <pay:item>
                     <pay:itemDetails>
                        <pay:fundCode>02</pay:fundCode>
                        <pay:reference>10948055</pay:reference>
                        <pay:amountInMinorUnits>250</pay:amountInMinorUnits>
                     </pay:itemDetails>
                     <pay:lineId>001</pay:lineId>
                  </pay:item>
               </pay:items>
            </pay:sale>
         </tem:request>
      </tem:Invoke>
   </soapenv:Body>
</soapenv:Envelope>

Open in new window


Try first to send a request with SOAP UI.
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Many thanks

I've taken that and tried to call it like I've always done but I'm now getting no reply at all for some reason. I've kind of been dumped in the deep end unfortunately. If I could just get some sort of reply that would be a building block.

This is what I'm trying.:

<?php

date_default_timezone_set("UTC");
ini_set("soap.wsdl_cache_enabled", 0); 

// prepare the full SOAP payload
$SOAPPayload = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pay="http://www.capita-software.co.uk/software/pages/payments.aspx?apnPortal" xmlns:com="https://support.capita-software.co.uk/selfservice/?commonFoundation">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Invoke>
         <tem:request>
            <pay:credentials>
               <com:subject>
                  <com:subjectType>SecureBureauServiceSite</com:subjectType>
                  <com:identifier>242</com:identifier>
                  <com:systemCode>APN</com:systemCode>
               </com:subject>
               <com:requestIdentification>
                  <com:uniqueReference>15439246051052</com:uniqueReference>
                  <com:timeStamp>20181204115645</com:timeStamp>
               </com:requestIdentification>
               <com:signature>
                  <com:algorithm>Original</com:algorithm>
                  <com:hmacKeyID>1</com:hmacKeyID>
                  <com:digest>AWO5unhlwNTbTxfaus7DX8/cM0l/WDGIjJdNBQZjSEQ=</com:digest>
               </com:signature>
            </pay:credentials>
            <pay:login>
               <pay:loginName>test</pay:loginName>
               <pay:password>testpwd</pay:password>
               <pay:consortiumCode>6Q</pay:consortiumCode>
               <pay:siteId>242</pay:siteId>
            </pay:login>
            <pay:requestType>PayOnly</pay:requestType>
            <pay:requestId>15439246051052</pay:requestId>
            <pay:routing/>
            <pay:sale>
               <pay:items>
                  <pay:item>
                     <pay:itemDetails>
                        <pay:fundCode>02</pay:fundCode>
                        <pay:reference>10948055</pay:reference>
                        <pay:amountInMinorUnits>250</pay:amountInMinorUnits>
                     </pay:itemDetails>
                     <pay:lineId>001</pay:lineId>
                  </pay:item>
               </pay:items>
            </pay:sale>
         </tem:request>
      </tem:Invoke>
   </soapenv:Body>
</soapenv:Envelope>';

$headers = array(
	"Content-type: text/xml;charset=\"utf-8\"",
	"Accept: text/xml",
	"Cache-Control: no-cache",
	"Pragma: no-cache",
	"SOAPAction: http://tempuri.org/IPortalService/Invoke",
	"Content-length: ".strlen($SOAPPayload)
);

// PHP cURL  for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, _SOAP_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $SOAPPayload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FAILONERROR, true);

echo curl_error($ch);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

?>

Open in new window

girionisCommented:
What happens if you try the same request from SOAP UI? Does it work? I tried it here and I got an error about invalid credentials, so it should work.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Neil ThompsonSenior Systems DeveloperAuthor Commented:
Can I use that online or do I need to install it and configure it all please?
girionisCommented:
You need to download it from here: https://www.soapui.org/
Neil ThompsonSenior Systems DeveloperAuthor Commented:
I've got that now but guttingly I think that is way over my head at present to learn in the next few hours how to use it. I only have until tomorrow pm to try to get a response unfortunately :(

The SOAP seems different in your one though to the one the company are giving as a test.

Their request is:
<invokeRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <credentials>
    <subject>
      <subjectType>SecureBureauServiceSite</subjectType>
      <identifier>242</identifier>
      <systemCode>APN</systemCode>
    </subject>
    <requestIdentification>
      <uniqueReference>3rdPartyRef20999</uniqueReference>
      <timeStamp>20181204124842</timeStamp>
    </requestIdentification>
    <signature>
      <algorithm>Original</algorithm>
      <hmacKeyID>1</hmacKeyID>
      <digest>XSEyKHlJ/i/af3K13d9Fl9ff2MMURm8Z8qP3JgAWUGI=</digest>
    </signature>
  </credentials>
  <login>
    <loginName>123</loginName>
    <password>456</password>
    <consortiumCode>6Q</consortiumCode>
    <siteId>242</siteId>
  </login>
  <requestType>PayOnly</requestType>
  <requestId>2b9a3a0f-9c01-4f14-87b2-9112f2e968f9</requestId>
  <sale>
    <items>
      <item>
        <itemDetails>
          <fundCode>02</fundCode>
          <reference>10948055</reference>
          <amountInMinorUnits>250</amountInMinorUnits>
        </itemDetails>
        <lineId>001</lineId>
      </item>
    </items>
  </sale>
</invokeRequest>

Open in new window


Which gives a response using their text exe file of:

<invokeResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ExtensionData />
  <requestId>2b9a3a0f-9c01-4f14-87b2-9112f2e968f9</requestId>
  <apnReference>ff4e2558-c813-437e-af76-6565e7171695</apnReference>
  <transactionState>InProgress</transactionState>
  <invokeResult>
    <ExtensionData />
    <status>Success</status>
    <errorDetails>
      <ExtensionData />
      <errorId />
      <errorMessage />
    </errorDetails>
    <redirectUrl>https://pay360sc.e-paycapita.com/LivePayments242/PortalLogin.aspx</redirectUrl>
  </invokeResult>
</invokeResponse>

Open in new window

girionisCommented:
I think their XML is wrong. For a start the operation is called Invoke

<wsdl:operation name="Invoke">
	<soap:operation
		soapAction="http://tempuri.org/IPortalService/Invoke" style="document" />
	<wsdl:input>
		<soap:body use="literal" />
	</wsdl:input>
	<wsdl:output>
		<soap:body use="literal" />
	</wsdl:output>
</wsdl:operation>

Open in new window


Inside the Invoke request there can be 0 or more elements named "request" of type "invokeRequest"

<xs:element name="Invoke">
	<xs:complexType>
		<xs:sequence>
			<xs:element minOccurs="0" name="request" nillable="true"
				type="q3:invokeRequest" />
		</xs:sequence>
	</xs:complexType>
</xs:element>

Open in new window


and the invoekRequest element can have the following elements:

<xs:complexType name="invokeRequest">
	<xs:sequence>
		<xs:element minOccurs="0" name="credentials"
			nillable="true" type="q4:credentials" />
		<xs:element name="login" nillable="true"
			type="tns:loginDetails" />
		<xs:element name="requestType" type="q5:RequestType" />
		<xs:element name="requestId" nillable="true"
			type="xs:string" />
		<xs:element name="routing" nillable="true"
			type="tns:routing" />
		<xs:element minOccurs="0" name="billing" nillable="true"
			type="tns:billingDetails" />
		<xs:element name="sale" nillable="true" type="tns:sale" />
	</xs:sequence>
</xs:complexType>

Open in new window


So the correct XML is the one I posted, which was produced by SOAP UI. By the way SOAP UI is very simple and easy to use, it won't take you more than 5' to set up a soap project and send a request.

Anyway, I think they have sent you a wrong sample XML request. YOu better get in touch with them and send them my request and ask them if it is correct.
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Thanks, I'll continue to look at SoapUI. Rather annoying when it all doesn't seem to work unfortunately though.

Strangely, this is their XML actually working in their text program I have on my pc

soap
girionisCommented:
Does the text programme you have connect to the new URL or to the old one?
Neil ThompsonSenior Systems DeveloperAuthor Commented:
girionisCommented:
This is what I get when I run it from SOAP UI. As you see I get a response back that I use wrong credentials:

https://prnt.sc/lql9bm
girionisCommented:
it connects to https://pay360sc.e-paycapita.com/LivePayments242/PortalService.svc

Are you sure? How do you know it? Do you pass it as parameter?

As a side note, if I send your request with SOAP UI I get an empty response with the following error:

HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 04 Dec 2018 14:21:23 GMT
Content-Length: 0

I think it is the same behaviour you get with PHP. Can you try to print the response headers as well?
Neil ThompsonSenior Systems DeveloperAuthor Commented:
I'm literally getting nothing at all back in the headers.

As for the URL, the config file has that in there, whether it's ignored and it actually goes somewhere else I'm not overly sure now as nothing seems to be tying up
girionisCommented:
Can you try something else? Can you delete the URL from the config file and try again? By doing so we'll make sure that it reads it from there.
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Thanks Girionis. I've tried that and it wouldn't work at all so at least I now know it's definitely going to that url, what I guess I don't know is how much "tweaking" is goin on under the hood before it's passed out.

Tried using Fiddler to try and catch the test .exe file output but it says it doesn't trust the certificates which is a shame
girionisCommented:
I still think your best bet is to try SOAP UI. If it works from there then you are certain what the request/response should be.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Thanks Gironis

Using SoapUI I managed to eventually find out they had changed part of the digest creation to be completely different to all the other digest creations they use. Unfortunately for us they didn't check all the samples I was sending them as they would have spotted it instantly.

Great help, much appreciated.
girionisCommented:
Ah... I see. I told you SOAP UI is a great tool. Glad I was of help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Curl

From novice to tech pro — start learning today.