<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged curl</title>
<link>https://overflow.efficy.io/?qa=tag/curl</link>
<description>Powered by Question2Answer</description>
<item>
<title>[SOLVED] Raising a SOAP request to Efficy CRM using curl gives &quot;Unexpected error: Incorrect SOAP Request&quot;</title>
<link>https://overflow.efficy.io/?qa=3318/solved-raising-request-efficy-unexpected-incorrect-request</link>
<description>&lt;p&gt;I am testing the SOAP requests with curl, on Linux.&lt;/p&gt;

&lt;p&gt;This is the SOAP request I used: A file &quot;request.xml&quot;, with the following contents:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  &amp;lt;soapenv:Envelope  xmlns:efficy=&quot;http://www.efficy.com&quot; xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope&quot;&amp;gt;
  &amp;lt;soapenv:Header/&amp;gt;
  &amp;lt;soapenv:Body&amp;gt;
  &amp;lt;efficy:logon database=&quot;mydbname&quot; user=&quot;mydbusername&quot; password=&quot;mydbpassword&quot;/&amp;gt;
  &amp;lt;efficy:logoff/&amp;gt;
  &amp;lt;/soapenv:Body&amp;gt;
  &amp;lt;/soapenv:Envelope&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I then used the following curl command to raise the POST request:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  curl --header &quot;Content-Type: text/xml;charset=UTF-8&quot; --data request.xml https://eua.efficytest.com/efficy.dll/SOAP?SS_ID=1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Executing the above command gave the response as an HTML, saying&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Object Moved - This document may be found here:&lt;br&gt;
  &lt;a rel=&quot;nofollow&quot; href=&quot;https://eua.efficytest.com/crm/SOAP?SS_ID=1&quot;&gt;https://eua.efficytest.com/crm/SOAP?SS_ID=1&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Changed the command to use that URL instead, as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  curl --header &quot;Content-Type: text/xml;charset=UTF-8&quot; --data request.xml https://eua.efficytest.com/crm/SOAP?SS_ID=1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But that gave an error page as the response, saying:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[Error - 2018/06/19 11:06:16] Unexpected error: Incorrect SOAP Request&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Where could I be going wrong? &lt;br&gt;
What SoapAction should we use?&lt;/p&gt;

&lt;hr&gt;

&lt;p&gt;&lt;strong&gt;[SOLUTION]:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks a lot for the answers. &lt;/p&gt;

&lt;p&gt;Inspecting and comparing the request sent with the PHP code I mentioned in one of the comments here, and checking the request header for the curl request, found that the issue was with the way I passed the file name - we had to add an @ symbol to filenames, when passing to curl.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?php

$location_url = 'https://eua.efficytest.com/efficy.dll/SOAP';

$client = new \SoapClient(null, array(
    'location' =&amp;gt; $location_url,
    'uri' =&amp;gt; &quot;http://www.efficy.com&quot;,
    'trace' =&amp;gt; 1
));

try{
  $return = $client-&amp;gt;__soapCall(&quot;logon&quot;, array(
    'database' =&amp;gt; 'mydbname',
    'user' =&amp;gt; 'mydbusername',
    'password' =&amp;gt; 'mydbpassword'
  ));
  //Get response from here
  echo &quot;&amp;lt;pre&amp;gt;&quot;;
  print_r($client);
} catch (SoapFault $exception) {
  var_dump(get_class($exception));
  var_dump($exception);
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So this would be the correct command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -i  --header &quot;Content-Type: text/xml; charset=utf-8&quot;   --data @request.xml   https://eua.efficytest.com/crm/SOAP?SS_ID=1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(Command options: '-i' shows the response headers).&lt;/p&gt;

&lt;p&gt;And this would be the correct request file (request.xml):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;SOAP-ENV:Envelope
  xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;
  xmlns:ns1=&quot;http://www.efficy.com&quot;
  xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
  SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
&amp;gt;
  &amp;lt;SOAP-ENV:Body&amp;gt;
    &amp;lt;ns1:logon&amp;gt;
      &amp;lt;param0 xsi:type=&quot;xsd:string&quot;&amp;gt;mydbname&amp;lt;/param0&amp;gt;
      &amp;lt;param1 xsi:type=&quot;xsd:string&quot;&amp;gt;mydbusername&amp;lt;/param1&amp;gt;
      &amp;lt;param2 xsi:type=&quot;xsd:string&quot;&amp;gt;mydbpassword&amp;lt;/param2&amp;gt;
    &amp;lt;/ns1:logon&amp;gt;
  &amp;lt;/SOAP-ENV:Body&amp;gt;
&amp;lt;/SOAP-ENV:Envelope&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Using these two, I was able to get the Efficy Session ID in the response header. Here is an example output from the same:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[anto@anto curl-soap]$ curl -i  --header &quot;Content-Type: text/xml; charset=utf-8&quot;   --data @request.xml   https://eua.efficytest.com/crm/SOAP?SS_ID=1
HTTP/1.1 200 OK
Cache-Control: max-age=0
Content-Type: text/xml; charset=UTF-8
Server: Microsoft-IIS/8.5
Set-Cookie: EfficySession=77EF504D-33890B88; expires=Wed, 27 Jun 2018 14:47:43 GMT; secure; HttpOnly
X-XSS-Protection: 0
Content: 
X-Powered-By: ASP.NET
X-Powered-By: ARR/3.0
Date: Wed, 20 Jun 2018 12:47:42 GMT
Content-Length: 622

&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:ns1=&quot;http://www.efficy.com&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;&amp;gt;  &amp;lt;SOAP-ENV:Body&amp;gt;    &amp;lt;ns1:logon&amp;gt;      &amp;lt;param0 xsi:type=&quot;xsd:string&quot;&amp;gt;mydbname&amp;lt;/param0&amp;gt;      &amp;lt;param1 xsi:type=&quot;xsd:string&quot;&amp;gt;mydbusername&amp;lt;/param1&amp;gt;      &amp;lt;param2 xsi:type=&quot;xsd:string&quot;&amp;gt;mydbpassword&amp;lt;/param2&amp;gt;    &amp;lt;/ns1:logon&amp;gt;  &amp;lt;/SOAP-ENV:Body&amp;gt;&amp;lt;/SOAP-ENV:Envelope&amp;gt;
[anto@anto curl-soap]$ 
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=3318/solved-raising-request-efficy-unexpected-incorrect-request</guid>
<pubDate>Tue, 19 Jun 2018 09:48:04 +0000</pubDate>
</item>
</channel>
</rss>