Jump to content

Communicate with Web Service by API SOAP


Recommended Posts

I want to get some information from my shipping company about my shipping. They provied web API for that. I received from them unique key for authentication. They provided manul but only with php examples like this:

EXAMPLE1:

<?

$wsdl = 'http:// kurier.k-ex.pl/api/ws.php?wsdl';
$API_key= 'aabbccdd-eeff-gggg-iijj-kkllmmnnoopp';
$data= " <Dane>
    <NazwaMetody>PobierzListeIndendtyfikatorowPrzesylek</NazwaMetody>
    <Parametry>
        <DataUtworzenia>2012-12-10</DataUtworzenia>
        <IdentyfikatorXmlPrzesylki></IdentyfikatorXmlPrzesylki>
    </Parametry>
</Dane>";
$client = new SoapClient($wsdl);
$result = $client->__soapCall("CallMethod", array($API_key, $data));

?>

EXAMPLE2:

<?

$wsKey = 'aabbccdd-eeff-gggg-iijj-kkllmmnnoopp';
$params = array(
        'wsKey' => $wsKey,
        'NumeryPrzesylek' => array('314128345','223121322')
      );
$wsdl = 'http://kurier.k-ex.pl/api/ws_soap.php?wsdl';
$client = new SoapClient($wsdl);
$result = $client->AnulujPrzesylki($params);

?>

 

any idea how to get same result with AutoIt?

I tried this code:

$SOAPClient = objcreate("MSSOAP.SOAPClient")
$API_key = 'aabbccdd-eeff-gggg-iijj-kkllmmnnoopp'
$data= " <Dane>" & _
"    <NazwaMetody>PobierzListeIndendtyfikatorowPrzesylek</NazwaMetody>" & _
"    <Parametry>" & _
"        <DataUtworzenia>2012-12-10</DataUtworzenia>" & _
"        <IdentyfikatorXmlPrzesylki></IdentyfikatorXmlPrzesylki>" & _
"    </Parametry>" & _
"</Dane>"
local $arr[2]
$arr[0] = $API_key
$arr[1] = $data
$strReturn = $SOAPClient.__soapCall("CallMethod", $arr);

but it doesn't seems to work

any idea?

Link to comment
Share on other sites

  • Moderators

Pretty sure __soapCall() function is specific to the php code you're presenting.

I believe there is a SOAP udf in the example script forum that will help you.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Pretty sure __soapCall() function is specific to the php code you're presenting.

I believe there is a SOAP udf in the example script forum that will help you.

I think you are right.

btw:

1. Do I need to install any software to get to work with SOAP COM on my Windows 8.1? Like SOAP Toolkit? (can't find it on ms website)

2. How can I find "MSSOAP.SOAPClient" documentation or some list with all available methods?

Link to comment
Share on other sites

  • Moderators

As Ptrex has said in that thread, SOAP is basically a deprecated option.

I know nothing of using it, but the little research I just did on it, it seems it is just XML data processing.

If you don't have the php.exe on your end or a simple server setup... I'm curious if maybe you could use IE to cheat by injecting javascript into IE and processing it that way.

I'm a huge fan of stackoverflow... http://stackoverflow.com/questions/124269/simplest-soap-example

Maybe you could create an IE instance, use eval to process that javascript data and receive the data back.

Dunno, with no real access to anything, I'm not willing to put any real time into debugging the idea to be honest, but there is food for thought for you all the same.

Edit:

BTW, I love your avatar, makes me smile each time I see it! lol

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

If you don't have the php.exe on your end or a simple server setup

I do. It's called called "bamcompile" which can convert PHP file into exe file but when I try to compile my php script then I got error:

"Fatal error: Cannot instantiate non-existent class:  soapclient"

error line: $client = new SoapClient($wsdl);

I don't know what to do to make it works. Maybe it require to install some php library or something. 

 

I think it will be hard to make that code work with autoit. As you can see my php script has some weird array structure to pass through parameters (api key and request)

My solution is to create php server where I place the script and i will use parameters to send api key and request (http://localhost/script.php?key=xxxx?request=xxxx) and it will return html code with results which I can pass to autoit with this function:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "http://localhost/script.php?key=xxxx?request=xxxx")
$oHTTP.Send()
$HTMLSource = $oHTTP.Responsetext
Link to comment
Share on other sites

  • Moderators

Sometimes it's the bandaid that gets you moving on to the next hurdle.  Once you're at least able to get things working, you can always perfect the means later.  Good job.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...