I'm an experienced data analist with mostly SQL and R experience, little Python, and unfortunately little .NET and PHP exposure. I have searched extensively for anyone with a similar questions, but unfortunately I haven't found what I'm looking for.
Situation: I'm setting up an HDInsight cluster on Azure (with Apache Spark) and I need to pull in some data from a SOAP API (no restful API).
Problem: Where and how do I pull this data in? I thought the Logic App in Azure would be a suitable place. However, I don't quite succeed in calling on this API.
I do have a working PHP script with a proper API call. Here is a (part of) the syntax.
$client = new SoapClient('http://someURL?wsdl');
$webservice = new SoapClient('http://someotherURL?wsdl');
$session = $client->someOperationToLogin($var1, $var2, $var3);
$operation = $webservice->someOperationToGetData($session, $var4, $var5);
$session = $client->logout($session);
As you can see, I first need to obtain a session id and then use this session id in subsequent calls. As far as I understand, I can't get to this data through a simple HTTP request.
Questions:
Can I call this particular SOAP API directly through one of the existing connectors in the Azure Logic App
If (1) is not possible, can I make use of the existing PHP script? How and where?
Is there any other route I can follow to make use of the data through this SOAP API? For instance: using pyspark in the Spark/HDInsight Cluster?
I really appreciate your help and pointers.
You Can Make The Call Through The Normal HTTP Connector.
1- First Set Your Http trigger method to post and send it your xml Body.
HTTP Trigger
2- Make An Http Action with the url to Your Soap End like
abc.asmx
xyz.svc Http Call To Soap End
Don`t forget to set the Method To Post and Content-Type to text/xml as a header.
3- Finally Bind your Http Response to response action set the status code and body To the HTTP Action Status and Body Dynamically don`t forget to set to content type Here to text/xml as well Return Response Action
4- Finally Configure the run After for response component to sun after HttP Action Even If Faild , Cancled or time out Just to pass the Status code for every call Like That Right click on Response and configure run after conf Run After For response Action .
Here is The Full View Full Flow.
Like The Response If This helps.
There are no SOAP APIs called thru the existing connectors in Azure Logic App.
This is a list of Connectors and API Apps Reference: https://msdn.microsoft.com/en-us/library/azure/dn948518.aspx.
Their supported functions are all based on REST APIs via Http/Https.
All services & apis on Azure are almost based on REST APIs to compatible with crossover platform & language scenes.
But even so, you can create own SOAP APIs thru Azure App Service or Cloud Service.Please refer to http://azure.microsoft.com/en-us/documentation/services/app-service/api/ and https://azure.microsoft.com/en-us/documentation/articles/app-service-logic-arm-with-api-app-provision/.
In Azure HDInsight, you can pull in some data from Storage Service and Service Bus. If you want to use Azure Logic App, the exisiting connectors are Blob Connector and ServiceBus Connector, and even Dropbox Connector.
You can refer to the references below to use PHP script to access the Azure Storage & ServiceBus services linked as HDInsight resources to store/get or send/receive some data.
1.https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
2.https://azure.microsoft.com/en-us/documentation/articles/service-bus-php-how-to-use-queues/.
Best Regards.
It is now possible to create a REST API from a SOAP WSDL file through Azure API Management using the SOAP to Rest feature.
This can be accessed from:
Azure portal -> API Management services -> <Your API Management Service> -> APIs -> Add API -> WSDL
After this is set up, it is easy to access this API from other Azure products.
Related
I am new to AZURE O365 portal, I have created some users in azure portal.
How can I create API in Azure portal to get the user details which I have already created in the portal and are they users enabled or disabled using PHP.
I tried: I have created application and I created secret Id in the portal, then what I have to do, to generate API for user list using php.
please help on it.
Thanks
Sandeep
Not sure if I undestand you correctly: you created some users on the azure portal and you want to get these users using PHP?
Azure has many APIs, they also have an API for getting these users, here is the specification and example code (not in php, but I think still easy to understand):
https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http
Basically you can access that data using graphql client. There are many graphql libraries for php. But as I skimmed through the docs, you don't really need a library, just a way to create http requests, I recommend Guzzle.
Before you create that php code, I recommend to simply play with the API by using postman or other api client. If it works there, you can start to create the php code.
The code is basically a http POST request (or whatever is specified in the documentation). The request should contain your API tokens in the header, thats all. Data will be provided usually as JSON. Here are some examples how to use guzzle in php for graph.
How to set up rest server and client.
I read the tutorial https://code.tutsplus.com/tutorials/working-with-restful-services-in-codeigniter--net-8814.
I got idea about restfull services , and rest server work fine , but rest client not.
My problem is I dont get the idea about rest client spark , And the given link CodeIgniter Curl library: http://getsparks.org/packages/curl/show was down , So cant get this.
How do I get this ?
The client mentioned in the post is merely for testing purposes. It is not part of the REST server.
What you need to set up in your code is the REST server library, method of authentication, database tables (if using any), and the controllers that will map your endpoints.
The client concept represents any device/application that will be consuming from or sending data to your REST service through the HTTP methods.
You could be using postman for your testing. It is free and open-source, and very intuitive to use.
I'm having troubles to figure out how web services handle requests and send responses, and how my site/module will handle it. So these are my questions and bellow a little about why i am asking this:
What is the right way to send a request to web service?
How a web-service will usually answer a site requesting?
How a PHP site can send a request to a web-service? Is cURL the right way?
I'm a student who are learning PHP and a lot of other things, and my job now is create a Joomla Module to show information from a web service (probably created in java or something, probably created by me, when i learn java...).
I know i will use http requests to talk with the web service, but i worry im using it wrong (making a request to the url, like the browser).
So, i did a little example site and a example API. The api uses Slim microframework to create routes, access my database and return the content in json (what means: if i access 'api.com/api/something' in my browser i see a plain white page with a lot of json). I pretend this is my web service.
The example site send a request to the API with cURL, reads the content and decode the json and do things. It seems forced to me.
I have not much support to understand web services and if i am in the right way (or far from this).
I would appreciate your help.
You are on the right track. A web service is simply a processing or storage facility intended to be accessed by some other program just like a database or fileserver service.
What is the right way to send a request to a web service
It depends. The most common implementations use SOAP or REST which define additional semantics on top of the HTTP protocol. SOAP uses a single URL as a gateway to the service and more specific selection of the functionality and the relevant data is embedded within an XML payload presented via POST. HTTP is merely a bearer for the message exchange. In REST, the HTTP part is integrated into the semantics of the transaction.
The URL identifies the location of the data (or processing function)
The payload contains only data, usually presented as POSTed JSON or XML,
further REST uses the HTTP verb (GET, POST, PUT, DELETE) to indicate the requested action
the HTTP headers are used to convey transaction meta-data.
How a web service will usually answer a request
I'm not sure what you are asking here. It should report back on the state of the request, any relevant error messages and possibly some data.
The speciifics would be unique to the API and documented.
Is cURL the right way?
While it is possible to do a lot with the HTTP wrappers functionality in PHP, libcurl offers an lot more flexibility. So, yes this it would be hard to implement a REST client without using cURL, OTOH a SOAP client is (usually) less complex at the HTTP tier but life is a lot simpler if you use a SOAP library/framework to abstract the more complex protocol.
For future questions please have one question per entry.
What is the right way to send a request to web service?
That really depends on the web service, what they require. It can be as simple as a short text string, to sending a XML formatted or JSON formatted array. You need to research the relevant web service.
How a web-service will usually answer a site requesting?
Again it depends on the web service. They are not the same. A web service will have documentation on what it expects and how it will respond.
How a PHP site can send a request to a web-service? Is cURL the right way?
Curl is a good method and is usually the method used from within PHP.
I have made a phonegap app and i want to know how to connect it to the database in my hosting website and add data?
Activate Internet permission and then use an AJAX like function to call a WEB API. This could be a script hosted from your hosting company which when called returns the data which you require in your app. This should ideally be in a standard format like JSON or XML.
Read more about REST APIs.
Read this to learn about REStfull APIs and Services.
See this post from 2011 which pulls a REST API.
API / Web Service is a code which can be written in any server side language like PHP. This script will communicate with with your Database.
These API/ Web service can be called from client, client can be a Web App / Web Site/ Mobile app, using HTTP METHODS (POST, GET etc). This API request will give response to the particular client with expected result (i.e. fetching data from database etc) and the response format can be JSON/ XML.
For more information you can Refer.
I have a WCF web service which allows both Basic HTTP and WS-HTTP clients, both over HTTPS using user name & password authentication. This is achieved with two bindings on the same service.
So, the service is at https://foo.com/Service.svc, the Basic HTTP (SOAP 1.1) endpoint is https://foo.com/Service.svc/Unp11, and the WS-HTTP (SOAP 1.2) endpoint is https://foo.com/Service.svc/Unp .
A client is trying to access this web service via PHP 5, using its built-in SOAP support, and is having trouble connecting to the service. He keeps getting an HTTP 400 (Bad Request) response, which tends to happen if the SOAP message is badly formed, or a SOAP 1.1 message is sent to a SOAP 1.2 endpoint (or vice versa).
I only know basic PHP so I'm having trouble helping him. I know you can create a client by doing
$client = new SoapClient('https://foo.com/Service.svc?wsdl');
but how do you specify the binding/endpoint? Are there any known issues achieving all this with PHP?
UPDATE
Ok, so I can use PHP to connect to the WCF service ok (specifying the SOAP version in the SoapClient constructor), and calling $client->__getFunctions() returns a correct list of all the web service operations.
When I try to call one using $client->__soapCall, the page just sits there loading for quite a while, and eventually returns the error "Error Fetching http headers". What exactly is this supposed to mean and how do I fix it? (Consuming the service from .Net client works perfectly.)
Just ran into this today, creating a WCF with multiple bindings for a PHP caller. Setting the location appears to allow for both the WSDL version of PHP's SoapClient and specifying a binding to use.
WCF config is (1 service with 2 bindings wsHttp and basicHttp), pretty straight-forward.
PHP code:
$client = new SoapClient("http://example.com/service.svc?wsdl");
$client->__setLocation("http://example.com/service.svc/basic");
$response = $client->MethodName(array( "paramName" => "paramValue" ... ));
We have a SOAP service which has several bindings. In C# when you add a service reference to a wsdl you get a class created for each one, but in PHP it seems you can't specify which binding you want to use - this has caused me problems when the bindings have conflicting type/method names. It does seem to generally work out OK though but I don't really know how it is dealing with it internally.
The other common problem I have had is that I always have to wrap up the parameters in loads of arrays or structs - sometimes you get a Bad Request back if the server is expecting a parameter and you haven't quite set it correctly. (see Having trouble getting my head around SOAP in PHP)
Not sure this is much help, just some thoughts. There are also some third-party Soap client implementations written in PHP that could be worth looking at, but they will be quite a lot slower.