API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

App identifier in SOAP request (PHP)

0

I tried to get the App identifier to work. But so far without success. I replaced the URL with:

https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Verify_XEconomicAppIdentifier

The SOAP library I have uses cURL. So I add an entry to my curl_headers array and do something like:

$curl_headers[] = 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER';
curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_headers);

But it does not work. The request is rejected. What am I doing wrong here?

 

created Sep 3, 2015 by ecodyr
0% Accept Rate
Q 6 A 10 C 1

1 Answer

0

This is a SOAP request, so using curl isn't that straight forward, but it is possible.

You need to add two more headers

X-EconomicAppIdentifier: YOUR APP IDENTIFIER
SOAPAction: http://e-conomic.com/Verify_XEconomicAppIdentifier
Content-Type: text/xml; charset=utf-8

Then you need to add a body
 
<?xml version="1.0" encoding="utf-8"?>
  <soap:Body>
    <Verify_XEconomicAppIdentifier xmlns="http://e-conomic.com" />
  </soap:Body>
</soap:Envelope>

That should work. It works for me.

answered Sep 4, 2015 by rbb
ecodyr
What was your solution?

I am really missing an example that works.

i used to connect like this:
    try
    {
    // Helper function to check query parameters.
    function checkParameter($param)
        {
        if (!$_REQUEST[$param])
            {
            echo "Missing <code>" . $param . "</code> parameter in query string.";
            exit(0);
            }       
        }
   
    checkParameter("agreementNumber");
    checkParameter("username");
    checkParameter("password");   

    $me = $_SERVER['PHP_SELF'];
    $wsdlUrl = 'https://api.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL';
    $client = new SoapClient($wsdlUrl, array("trace" => 1, "exceptions" => 1));
              
        $client->Connect(array(
        'agreementNumber' => $_REQUEST['agreementNumber'],
        'userName'        => $_REQUEST['username'],
        'password'        => $_REQUEST['password']));
    }
catch(Exception $exception)
    {
    print("<p><i>" . $exception->getMessage() . "</i></p>");       
    $client->Disconnect();
    }
   
now i should do what??
You can do it like here:

<?php
$opts = array(
  'http' => array(
    'header' => "X-EconomicAppIdentifier: RevirusDKInvoicing/1.0 (http://revi-rus.dk/; administrator@revi-rus.dk) PHP-SOAP/1.0\r\n"
  )
);
$context = stream_context_create($opts);
$this->client = new SoapClient(EconomicsWS::WSDL, array("trace" => 1, "exceptions" => 1, 'stream_context' => $context));

Or, you can try to use notes from here:
http://php.net/manual/en/class.soapheader.php
Hi,
I have a problem at here:
"X-EconomicAppIdentifier: MY APP IDENTIFIER"
I don't know where is this about "MY APP IDENTIFIER" in my app.
Someone can help me? And make demo for this.
Visma e-conomic A/S
...