How to handle SOAP service within persistent Perl web application with cookies? - web-services

Due to the fall of SOAP::WSDL which had generated me real Perl modules I have to look for something other in order to handle a SOAP service. The generated modules won't work starting from Perl v5.18.
I have the following situation with my web application.
I have a PSGI compatible, Dancer2 driven, persistent web application.
The web application handles multiple concurrent customers.
The web application is between the customer and an external SOAP service.
The SOAP service uses customer sessions via cookies which have to be integrated on the web application internally for the customer.
The web application holds an WSDL file copy of the SOAP service.
I'm looking for a module that creates an interface out of the WSDL file and handles parameter/schema validation and communication with the SOAP service. I would like to call a method (SOAP call) with parameters (SOAP call parameters) and receive a cleaned data or object structure of the response.
The problem is that the web application needs to handle multiple concurrent customer cookie sessions. So I need a module which offers the possibility to override the cookie jar for that particular request and extract the cookies after the request without causing interference with other concurrent requests.
I found XML::Compile which I can initialize as a singleton at web application start up. But with this solution I ran into problems with interfering other customer requests. So the requests are not separated. Initializing XML::Compile for every request is not the solution either because it will parse the WSDL and generate handlers over and over again for every request the customer sends to the web application.
Is there any solution/module that fits my needs or do I miss something with XML::Compile and it's possible with it?

Are you using Catalyst?
I've been happy using Catalyst::Controller::SOAP and its companion Catalyst::Model::SOAP to build SOAP/WSDL servers and consumers, being able to integrate Perl Applications even with Microsoft Document Literal-Wrapped thing.
Even if not using Catalyst you may probably learn from its code. It uses XML::Compile::WSDL11.

Related

Can a wcf client handle 2 version of a SOAP response from the same url?

I imported a service reference to a SOAP web service from the customer and coded my client based on that.
After going to production, they said they will launch a new version of the web service with changes to the output type of one of the requests I make to the service (among new messages that I don't consume).
I know I can update my service reference and update my client code to process the updated wsdl and launch an update to my client at the same time the web service updates.
But, is it possible to instrument the WCF code in some way so that I can handle both versions of the response without having to coordinate the update of my client with the update of the web service?
In most cases, NO. It depends on what has changes in the service interface? In most cases you'll need (and want) to upgrade your client. You can always ask them to support more versions of their interfaces.

Is this service Restfull?

I am not sure if this is the correct place to ask but since there are a lot of questions of this kind i ll go ahead and ask.
A year ago i developed an iOS application that was connecting to a server with HTTP requests exchanging JSON files etc. I was told at that time that the server was a web (REST) service. I didnt care much since for me was just a black box.
The last months i am developing a hybrid mobile application where i use native code + jquery mobile for the front end part and php + mysql for the back end part. The application is about registering new users to the data base , having users to subscribe in various kinds of events , get notifications on them etc. So for all the communication between the front ent(client) and back end(server) i make http requests(POST) , ajax calls using json files.
Is this a RESTfull Web Service? I am a bit confused on the definition of REST. According to wikipedia REST is :
REST-style architectures conventionally consist of clients and servers. Clients initiate requests to servers; servers process requests and return appropriate responses.
So is what i am building a Restfull Web Service? Also do we call Rest only the server part or in general the client-server architecture?
Is it just a web Service? And if yes what kind of web service?
there is no difference when you invoke a controller (aka web service) from browser through http or from a client code (java, .NET or any language). when you want to invoke a service from outside world from your code.. you have choice of soap or rest .. soap is protocol, where as REST is an architecture style.. so REST is methodology of calling a service (which is simple http POST or GET call) from outside world .. not necessarily from a browser .. it may from client code which acts as browser to get response from outside world service..this is based on my experience..

regarding webservices

I've started learning about webservices recently. Have few question about that:
For webservice, is it always necessary that source should provide wsdl or any other way possible to consume it without needing wsdl?
Till a while ago, I was doing server side XMLhttp post in classic ASP to do modifications in external application & to push data in my application from external application. I'm confused - is that very different from webservice or can be called a sort of webservice(ofcourse without based on SOAP). Any major difference or it is just protocol difference bw webservice and server side XMLhttp post?
Web services can be made asynchronous?(Something like AJAX call through javascript)
Are there any different types of webservices ? (for e.g is there difference bw, webservice providing stock quotes and webservice provided by google)
1.For webservice, is it always necessary that source should provide wsdl or any other way possible to consume it without needing wsdl?
WSDL is a document that publishes an interface. As long as a client complies to the inteface, it is guaranteed to be able to "talk" to the web service. Having said that WSDL is a formal way for a specification when there are many stakeholders. You can proceed without one, as long as you somehow know what the web service expects. Just wrap the application data in a SOAP envelope and send it to the web service. As long as you send what the web service expects (in the SOAP envelope or the application data) and in the way they are expected e.g. transport HTTP etc. it does not matter for the WS if you have used a WSDL or not.
2.Till a while ago, I was doing server side XMLhttp post in classic ASP to do modifications in external application & to push data in my
application from external application. I'm confused - is that very
different from webservice or can be called a sort of
webservice(ofcourse without based on SOAP). Any major difference or it
is just protocol difference bw webservice and server side XMLhttp
post?
In very simple terms web service is XML over some application protocol (usually HTTP). Could be SOAP based or REST. To understand more on this you should read about Service Oriented Applications
3.Web services can be made asynchronous?(Something like AJAX call through javascript)
They could but it is more complicated than that.
4.Are there any different types of webservices ? (for e.g is there difference bw, webservice providing stock quotes and webservice
provided by google)
Not sure what you ask here. Each web service offers something.
I will try to be very simple here:
The W3C defines a "Web service" as "a software system designed to
support interoperable machine-to-machine interaction over a network".
That means first requisite for any software to be web-service is that it should not depend upon platform or software i.e a web service made on java stack can be consumed by client in .net stack on windows or java stack on android.
If your server side implementation XMLhttp post suffice this ,its a
web service.
Types of Web services
Actually, there is no overall and clear categorization on types of web services. But two most popular are :
SOAP based web services. :It use XML messages that follow the Simple Object Access Protocol (SOAP) standard, an XML language defining a message architecture and message formats(WSDL).
REST based web services. With evolution of WEb 2.0 emphasis has been moving away from SOAP based services towards representational state transfer (REST) based communications.[3] REST services do not require XML, SOAP, or WSDL service-API definitions.Read here to get a easy explanation of REST
Need of WSDL to consume SOAP web services?
To consume a SOAP service we only require SOAP endpoint and XML message format. WSDL is a pre-requisite for automatic client side code generation through Java and .NET SOAP frameworks.
Asynchronous web services
Making web services asynchronous is possible.But complexity depends upon frameworks used, for example AXIS2 in JAVA has easy implementation of this.

Send XML file to Web Service using Java

I want to send an XML file to a Web Service.
The Web Service is a java application.
I know the endpoint of the Web Service.
Typically I know I have to create the request and send it as an http/https request.
What I want to know is what would I have to make to send the request - as in what development tool could I use e.g. Visual Web Developer (preffered as I am familiar with this) or Visual Studio? And what sends the request - e.g. another Web Service, a Website etc?
Where do I even begin with this?
Any comments are much appreciated.
Where do I even begin with this?
One purpose of a Webservice is loose coupling. So it depends on what you want to do. You can write a simple program in what ever language which constructs a request and sends it. You can write a Webservice on its own which uses the other Webservice to handle it's own requests.
You can handle this in a very simple or complex way. You only need to be able to generate a request (per xml) and send it.

Web Service Interface

I'm looking to add a web services interface to an existing server application. The set of services to expose is not known at compile time and can change over the runtime life of the server.
From a tech standpoint all the server/web services endpoints will be on Windows.
In our server app a user will have the option to register workflows as 'web services callable'. This will create the WSDL defining this particular workflow service.
For the calling endpoint I'm thinking of an HttpModule that accepts the inbound web service request, unpacks the request and converts the XML data types into our server applications "domain", calls the server and finally converts the server outputs back into XML for return down the http connection.
Does that make sense?
Critical comments welcomed.
In effect writing your own WS engine. Clearly doable, but quite a bit of work to get right from scratch. I guess if you find some open source implementation, then adapting it should be possible.
A rather dirtier alternative, but one I've seen applied in another context, is to go for a simgle WS interface
String call( String workkFlowName, String payload)
The payload and response are both Strings containing any XML. So the caller needs to undestand the schemas for those XMLs. From the client's perspective the amount of coding effort is not much different. Your coding effort would I think be significantly redcued.
an HttpModule that accepts the inbound
web service request, unpacks the
request and converts the XML data
types into our server applications
"domain", calls the server and finally
converts the server outputs back into
XML for return down the http
connection.
That is what all web service frameworks do (e.g. Metro, Axis). So I can't see your problem. What's your concern with this approach?
The downside for the client is that, as far as I understand it, availability of your services may change over time. So you should consider a way to inform the client if the service is available (other than getting a time out error because it is not there), e.g. WS-ResourceLifetime or UUDI.
I ended up creating a C# class that implements the IHttpHandler interface. The implementation serves up the WSDL of the services exposed from our app and accepts SOAP posts to invoke the services. In the end most of the work went on converting SOAP types to our types and vice versa.