Hi,
I am trying to connect to SOAP based webservice from Matrix. When i am going through manuals it explains how to expose Matrix services to outside world using SOAP API. Is it that Matrix doesn't support integration of external SOAP based services the way it supports REST based servcies?
SOAP based webservices
[quote]
Hi,
I am trying to connect to SOAP based webservice from Matrix. When i am going through manuals it explains how to expose Matrix services to outside world using SOAP API. Is it that Matrix doesn't support integration of external SOAP based services the way it supports REST based services?
[/quote]
That's right, Matrix only has a SOAP API to expose parts of Matrix externally. There has been nothing developed generically to support the integration of external SOAP APIs, there has been some custom development for individual clients in the past, but these are targeted for custom SOAP apps (be these would be useless to anyone else).
Development of any sort of SOAP integration would be a lot harder to achieve than the respective REST service, because the SOAP communication requires XML both passed in and received, while REST merely takes a URL in and XML is received from that. And developing something generically would take a fair bit of thought to make it a clean interface but powerful and flexible enough for most solutions.
To connect to web services (whether they're REST or SOAP) you really only have 2 options:
- REST Resource Asset (for GETs)
[*]Custom Form Asset (for POSTs)
The REST Resource Asset requires you to hard-code the XML, where as the Custom Form Asset can read the WSDL and gives you actual methods that you can call.
P.S. I realise you can use Remote Content, but its really only useful for web services that generate HTML output.
Was there anything specific you wanted to know?
I'm totally new to webservices, so forgive me for the noob question.
Is it possible to get Matrix connect to a external WSDL webservice created by ColdFusion?
I'm trying to display price and reviews.
Thanks.
[quote]
I'm totally new to webservices, so forgive me for the noob question.
Is it possible to get Matrix connect to a external WSDL webservice created by ColdFusion?
[/quote]
You can do this with javascript. Just google jQuery SOAP.
Cool, i will look into this.
So you don't actually have to use the Rest API asset?
[quote]
Cool, i will look into this.
So you don't actually have to use the Rest API asset?
[/quote]
Just remember, you can do SOAP with JS (SOAP is just a way of encapsulating a message) but only if it's within the same domain. If you're doing this cross-domain you'll still need to use REST.
[quote]
Just remember, you can do SOAP with JS (SOAP is just a way of encapsulating a message) but only if it's within the same domain. If you're doing this cross-domain you'll still need to use REST.
[/quote]
Thanks for this addition.
Just as a note to the accessing of content through jquery…
If you intend for these pages to be indexed and would like the content for these pages to be included then you need to ensure that the request happens on the server (Rest asset)
Thanks for the feedback.
Yes, the pages will be indexed and yes it will be cross domain.
I ran the test from Rest Resource asset and it seems to connect successfully (below), but where do you write your code to make the calls?
"request" => array ( "method" => "GET", "headers" => array ( [Empty] ), "body" => "", "urls" => array ( 0 => "http://www.hbstaging.net/api/remote/hbcontentcurrency.cfc?wsdl" ), "auth" => array ( "type" => "OAuth" ), "oauth_headers" => array ( [Empty] ), "url" => "http://www.hbstaging.net/api/remote/hbcontentcurrency.cfc?wsdl" ), "responses" => array ( 0 => array ( "body" => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n array ( "Content-Type" => "text/xml; charset=utf-8", "Server" => "Microsoft-IIS/7.5", "Set-Cookie" => "CFTOKEN=931e0741b4edeb54-3E6A0378-DFE0-63D9-5109B67D8BE5F8EA;domain=.hbstaging.net;expires=Thu, 09-Jan-2042 17:13:54 GMT;path=/", "X-Powered-By" => "ASP.NET", "Date" => "Tue, 17 Jan 2012 17:13:54 GMT", "Content-Length" => "50927" ), "info" => array ( "url" => "http://www.hbstaging.net/api/remote/hbcontentcurrency.cfc?wsdl", "content_type" => "text/xml; charset=utf-8", "http_code" => 200, "header_size" => 400, "request_size" => 93, "filetime" => -1, "ssl_verify_result" => 0, "redirect_count" => 0, "total_time" => 0.066341, "namelookup_time" => 0.000977, "connect_time" => 0.007358, "pretransfer_time" => 0.007382, "size_upload" => 0, "size_download" => 50927, "speed_download" => 767654, "speed_upload" => 0, "download_content_length" => 50927, "upload_content_length" => 0, "starttransfer_time" => 0.044762, "redirect_time" => 0 ), "source" => "remote", "expiry" => 0 ) ), "response" => array ( "body" => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n array ( "Content-Type" => "text/xml; charset=utf-8", "Server" => "Microsoft-IIS/7.5", "Set-Cookie" => "CFTOKEN=931e0741b4edeb54-3E6A0378-DFE0-63D9-5109B67D8BE5F8EA;domain=.hbstaging.net;expires=Thu, 09-Jan-2042 17:13:54 GMT;path=/", "X-Powered-By" => "ASP.NET", "Date" => "Tue, 17 Jan 2012 17:13:54 GMT", "Content-Length" => "50927" ), "info" => array ( "url" => "http://www.hbstaging.net/api/remote/hbcontentcurrency.cfc?wsdl", "content_type" => "text/xml; charset=utf-8", "http_code" => 200, "header_size" => 400, "request_size" => 93, "filetime" => -1, "ssl_verify_result" => 0, "redirect_count" => 0, "total_time" => 0.066341, "namelookup_time" => 0.000977, "connect_time" => 0.007358, "pretransfer_time" => 0.007382, "size_upload" => 0, "size_download" => 50927, "speed_download" => 767654, "speed_upload" => 0, "download_content_length" => 50927, "upload_content_length" => 0, "starttransfer_time" => 0.044762, "redirect_time" => 0 ), "source" => "remote", "expiry" => 0 )
[quote]
I ran the test from Rest Resource asset and it seems to connect successfully (below), but where do you write your code to make the calls?
[/quote]
If you're using the rest resource you make the calls directly with the request url, and then you deal with the response with javascript which is run on the server before passing through the final html to the page.
This is not a multithreaded request model where you can make a secondary request based on the information returned from your initial request.
The most common use would be to pass dynamic variables into the URL in the REST request using the current page keywords.
In your situation you would probably store the ID of the product as metadata, and then pass that keyword into the URL rest query back to your coldfusion API. That will return the relevant price and description which you then wrap in the appropriate html to display on the page.
I don't think you can request from the url directly, as it requires API Key.
This might sound dumb but where do you actually write the code (json) to make the request in the first place with the Rest Resource asset?
Here is the example XML structure from the documentation.
getPropertyReviews() get xml packet detailing the user reviews for a specified property Please note: A review rating is only calculates after a property has had 6 or more reviews Request parameter description key Int, Webservice access key property Int. The id number for the property totalReviews Int. The number of reviews for the property. Maximum value for this field is 25. Sample Response 1: <?xml version="1.0" encoding="UTF-8"?> Sample Response 2: <?xml version="1.0" encoding="UTF-8"?> invalid authorization key
and another example (get) in PHP (SOAP)
<?php require_once('nusoap.php');// set up a function for make our SOAP requests function doSoapRequest($method,$args){ $host=’http://www.hbstaging.net/api/remote/hbcontentcurrency.cfc?wsdl’; // add key to args array. key must always be sent! $args['key']=’123456789’; // create the client instance $client = new soapclient($host, true); // call the SOAP method $result = $client->call($method,$args); if ($client->fault) { // check for a fault & display it echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; die(); } else { // check for error $err = $client->getError(); if ($err) { // show error echo '<h2>Error</h2><pre>' . $err . '</pre>'; die(); } else { // return the response return $result; } } } // make a soap request to get the list of countries in Europe, in German language $r1=doSoapRequest('getCountryList',array('language'=>'de','continent'=>'eu')); // show response array echo ‘<pre>’; print_r ($r1[‘RESPONSE’]); echo ‘</pre>; // make a soap request to get the city details and list of bookable properties in Oslo, Norway getLocationList() or getCountryData() request $r2=doSoapRequest('getLocationData',array('language'=>'en','country'=>'norway','location'=>'oslo')); // show response array echo ‘<pre>’; print_r ($r2[‘RESPONSE’]); echo ‘</pre>; ?>