0 votes

I am testing the SOAP requests with curl, on Linux.

This is the SOAP request I used: A file "request.xml", with the following contents:

  <soapenv:Envelope  xmlns:efficy="http://www.efficy.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope">
  <soapenv:Header/>
  <soapenv:Body>
  <efficy:logon database="mydbname" user="mydbusername" password="mydbpassword"/>
  <efficy:logoff/>
  </soapenv:Body>
  </soapenv:Envelope>

I then used the following curl command to raise the POST request:

  curl --header "Content-Type: text/xml;charset=UTF-8" --data request.xml https://eua.efficytest.com/efficy.dll/SOAP?SS_ID=1

Executing the above command gave the response as an HTML, saying

Object Moved - This document may be found here:
https://eua.efficytest.com/crm/SOAP?SS_ID=1

Changed the command to use that URL instead, as:

  curl --header "Content-Type: text/xml;charset=UTF-8" --data request.xml https://eua.efficytest.com/crm/SOAP?SS_ID=1

But that gave an error page as the response, saying:

[Error - 2018/06/19 11:06:16] Unexpected error: Incorrect SOAP Request

Where could I be going wrong?
What SoapAction should we use?


[SOLUTION]:

Thanks a lot for the answers.

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.

<?php

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

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

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

So this would be the correct command:

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

(Command options: '-i' shows the response headers).

And this would be the correct request file (request.xml):

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

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

[anto@anto curl-soap]$ curl -i  --header "Content-Type: text/xml; charset=utf-8"   --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

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.efficy.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">  <SOAP-ENV:Body>    <ns1:logon>      <param0 xsi:type="xsd:string">mydbname</param0>      <param1 xsi:type="xsd:string">mydbusername</param1>      <param2 xsi:type="xsd:string">mydbpassword</param2>    </ns1:logon>  </SOAP-ENV:Body></SOAP-ENV:Envelope>
[anto@anto curl-soap]$ 
asked in Errors by (104 points)
edited by

2 Answers

+2 votes

The header should be removed, this creates invalid XML.

<soapenv:Header/>

When you have invalid XML, Efficy redirects to the error page defined in admin/Error.htm. Sadly, this is the same error page as for the end user, so you get HTML back instead of XML

If you create an isolated website for SOAP requests on a new inetpub folder containing Efficy.dll and the admin/ folder, you could change the admin/Error.htm to contain an XML structure.

FYI, I prefer using Postman compared to SOAP-UI, mainly because it offers less functionality, making the overview better. Secondly, I don't like Java based applications ;-)

Postman

answered by (6.8k points)
edited by
Thank You, Kristoff! Trying this now
"I don't like Java based applications ;-)" do you want to share a bad experience with us Kristof^^?

Soap-Ui offers a huge advantage when you have to work with an outside provider. Once you show him that your API works in soap-UI or that his doesn't he won't contest your method and try to fix the issues himself^^. LOT of time and mails saved just because of soap-ui fame.
I'm sure it's more the developers fault and not Java. Java based GUI's are to my experience ugly, slow, single threaded. Look at SQL Developer for instance... it combines all these troubles.
Kristof, that the SOAP connection seems working now, is there a way to find the table structures used in our account, so that we could use that to fetch data from it?
You can inspect your database structure using the Efficy Designer. What are you trying to achieve by the SOAP messages?
Thank You, will try using Efficy Designer.
Playing with the SOAP API create a script to sync some listings from our Efficy CRM to our website (PM-ed the details to you).
+1 vote

can you try your soap request using Soap-Ui or something like that?

this is a way to set a soap request with no wsdl :

  • Create new SOAP Project using File > New SOAP Project
  • Set the name as required
  • Leave the initial WSDL field blank
  • On the Project Navigator Window to the left, mouse over the project
    folder and select New Rest Service from URI using the context menu
  • Enter the enpoint you would like to send a SOAP message to, i.e.
    http://yourservername/crm/soap
  • Choose POST as the HTTP method
  • Add your xml SOAP payload to the window in the bottom left
  • Choose media type: text/xml from the combobox
  • Click to green arrow to POST the message to the specified endpoint
  • And voilà - you should see the SOAP response on right-hand side
    window :)

at least you should be able to test if you have an error not depending of the way of calling the service

answered by (983 points)
Thank You, @Louis!

I was able to get it working with the following PHP code:

<pre><code>
<?php

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

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

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


Trying to understand what went wrong with that curl command.
(Have to use that to automate this on the Linux shell).


Also, I don't seem to be able to get through the documentation, to figure out how to fetch some items from the Efficy DB.

How do you guys usually get help on this?
the few times I had to use it, I firstly parse the response, with a xml2json library or something like this. then I use the caller scripting techno to parse and compute my result.

what exactly do you mean by "how to fetch some items"?

About the cUrl syntax I never used it so I won't be able to help you on this...
But I guess it's easy to just send a url to your PHP server from Linux from a chron task. Then you can delegate the job of building the soap request to your php server and then parsing and computing the result.

Please be sure you use a safe enough way of doing that because you definitly don't want that every single request to your server trigger the soap job^^.
Response parsing seems pretty straightforward.

I was searching for a way to fetch the full list of contacts from the DB - how do we query / what request do we use for that?
you have a method that allow you to display the result of a query through soap
so just use something like that :

                               <efficy:api>
                                               <datacontainer id="5" operation="query" master="-1" param1="jstpvcalu@gmail.com" param2="212C44532" detail="48" includeblobcontent="true"/>
                               </efficy:api>

just create your query with efficy first^^
is that what you were looking for?

what I love with that solution is that you can give the fetchable content result settable to the customer by modifying or not the queries.
Thank You! Efficy Query looks very much like what I am after. :-)

Where did you find that in the Efficy documentation? I couldn't find that from my searches.
I ve found this in an old custom I ve made but it seems to be documented here

https://help.efficy.com/edn/dev/dnsp_appendix_soap_requests

apparently you can even use a nativesqlquery...
That's what I love with Efficy you have something that powerfull available somewhere in the deeps of a FAQ section^^
Louis, you saved my day. Thank You!

Will try this out and let you know.

Thank You!
Welcome to Efficy Overflow, where you can ask questions and receive answers from other members of the community.
1,167 questions
1,425 answers
1,717 comments
325 users