I want to share with you my interest in Web services, SOAP and the RCX brick, so I decided to develop a public Web services with Java 1.3 inferface WSDP RCX rover.
Web services are not always so easy, then it will be a tutorial on how to eat using Java, PHP, Perl, Python, C / C + + or C #. NET. I hope this guide will help beginners to use SOAP technology.
In my documentation, you’ll find sample code for a SOAP client in Java (JAX-RPC, Axis), PHP (NuSOAP), Perl (SOAP:: Lite), Python (and SOAPpy ZSI), C / C + + (gSOAP) , C # or VB.NET. All of this is eaten with the Java WSDP web service (document / literal).
You’ll also find some sections to demonstrate interoperability of cases for clients in JAX-RPC (Java), NuSOAP (PHP), SOAP:: Lite (Perl), or PyXML ZSI (Python), gSOAP (C / C + + on Linux or Cygwin) using Web services. NET.
Also included in the document it is the customers ‘HTTP Post’ in the following languages: Java, Perl and Python. The advantage of using a library of soap.
See my new chapter in the client using SOAP. NET Framework SDK free of charge with C # and VB. NET command line compiler.
I also have a chapter on gSOAP: SOAP client in C / C + +. Enter to gSOAP. Use gSOAP, it is very easy to handle complex types returned by way of soap, try it!.
Also learn to create, and how to register client side JAX-RPC handler. Demo how to draw handle SOAP messages. There is also a way to change the SOAP message received by contributing to the attribute using the DOM. Go to the JAX-RPC client manager.
New!
I’ll start documenting how to eat a secure Web service. So I wrote a small section shows how to configure SSL with Tomcat to access web services using HTTPS. The new section describes the configuration of the Tomcat SSL, server certificates and client certificates for the creation and testing of a Web browser that authoritative.
Previous
SOAP And The RCX Brick
Uses SOAP To Enable XML Web services
One of the most amazing uses of SOAP is to enable XML Web services. XML Web service is a function that is exposed through SOAP interface to other web application based soap that you can call this service. Can For example, credit authorization service SOAP interface to expose the application needs to check the creditworthiness of the customer to make SOAP call to get information.
There are two great advantages to using XML Web services:
- An XML Web service is a standard way to expose services your company provides to a large number of other users who need that services.
- XML Web services provide a way to combine services that other people provide and use them to build your own unique application.
By using XML Web services for common services such as credit verification, billing, and shipping, you application developers can concentrate on the unique value-added functions that your company provides.
There are significant issues involved in providing XML Web services, such as security, authentication, scalability, billing, and so on, but most of these issues are being resolved and XML Web services appear to be a part of almost every developer’s future. For more information on XML Web services, please see http://msdn.microsoft.com/webservices. For additional information on the topics covered in this article, please visit the links below:
- SOAP 1.1 and Related Specifications (http://www.w3.org/2000/xp/)
- Microsoft SOAP Toolkit (http://msdn.microsoft.com/soap)
- Emerging SOAP Specifications (http://www.gotdotnet.com/team/xml_wsspecs/default.aspx)
- .NET Framework (http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp)
Change The SOAP Web Service Into A REST Service
Change the SOAP web service I publish into a REST service. Any ideas on where I should be beginning with this?
It’s a good question, and I’m not surprised that there isn’t a whole lot on the internet about ColdFusion and REST, since it is so easy to create SOAP web services in CFML. So I thought this would make a good blog entry…
To start it is essential to understand what the differences between the REST architecture and the SOAP architecture are.
Next step would be to take a look at some actual REST web services that are popular, and well designed. If you are a visual learner like me this is an easy way to understand how they work.
- Flickr API – Flickr has API’s using REST, SOAP, and XML-RPC so it’s a good one to see the differences.
- Yahoo API’s – Many of the Yahoo API’s use REST.
- 37Signals API’s – Basecamp, Backpack, Highrise all use the REST approach.
Once you have translated all the SOAP method requests into an REST request requests implementing the service should not be that difficult. Just invoke your SOAP component methods locally, and format the response in XML.
Before chance to post this entry already implemented his REST service.
Coincidentally I’ve already worked on my own solution which seems to be working nicely. I simply created a ‘wrapper’ for my current SOAP webservice, that uses <cfinvoke> to invoke the webservice with the POST data sent by the REST call, and then reformat the XML data ready to be parsed, I hadn’t realized how simple it was, its actualy of benefit too me as it allows a more OO development approach to the service, and also makes for a much lower overhead and bandwidth.
Using onRequest In Application.cfc And Web Services
There are some issues with using onRequest in your Application.cfc and web services, but I didn’t think there were any issues with onRequestStart and ColdFusion 8 SOAP web services.
Today while working on one of my clients web services I started getting the error org.xml.sax.SAXParseException: Premature end of file. on any web service call. The web service worked fine a few days ago.
The problem was that another developer added the following to the existing onRequestStart:
<cfset var headers = GetHttpRequestData().Headers>
Apparently will cause bad things to happen. As a workaround I thought this would be a great use for the function IsSOAPRequest() added to CF7, I’ve never used it.
Well it turns out that IsSOAPRequest() always returns false in onRequestStart! (On ColdFusion 8, I haven’t tested this on 9)
I ended up using arguments.targetPage to condition calling GetHttpRequestData() and all was well.
Here’s the full stack trace I was getting:
org.xml.sax.SAXParseException: Premature end of file.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
at org.apache.axis.server.AxisServer.initSOAPConstants(AxisServer.java:345)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:279)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at coldfusion.xml.rpc.CFCServlet.doAxisPost(CFCServlet.java:270)
at coldfusion.filter.AxisFilter.invoke(AxisFilter.java:43)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.xml.rpc.CFCServlet.invoke(CFCServlet.java:138)
at coldfusion.xml.rpc.CFCServlet.doPost(CFCServlet.java:289)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Implementations Of SOAP
The SOAP::Lite toolkit is one of the most complete implementations of SOAP available, supporting both Versions 1.1 and 1.2 of SOAP. It has strong support for alternate transports (FTP, HTTP, IO, Jabber, SMTP, POP3, TCP, and MQSeries), which we’ll use later to demonstrate SOAP over Jabber.
SOAP::Lite, like many Perl modules, is available on the Comprehensive Perl Archive Network (CPAN). CPAN is a network of web and FTP sites with identical content–the source to thousands of Perl modules. You can access CPAN through a Perl command-line client or via the Web
Example: Installing SOAP::Lite with the CPAN shell
C:\book>perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.59_54)
cpan> install SOAP::Lite
(You may be walked through configuring the CPAN shell if this is the first time you have run it.) The CPAN shell will connect to a CPAN site and download the source for SOAP::Lite. Once downloaded, the shell will attempt to build the module. SOAP::Lite has a series of interactive steps to configure the module, shown in Example. You can either use a default configuration or manually select from a menu of options to build a custom configuration.
We are about to install SOAP::Lite and for your convenience will
provide you with list of modules and prerequisites, so you'll be able to
choose only modules you need for your configuration.
XMLRPC::Lite, UDDI::Lite, and XML::Parser::Lite are included by default.
Installed transports can be used for both SOAP::Lite and XMLRPC::Lite.
Client (SOAP::Transport::HTTP::Client) [yes]
Client HTTPS/SSL support
(SOAP::Transport::HTTP::Client, require OpenSSL) [no]
Client SMTP/sendmail support (SOAP::Transport::MAILTO::Client) [yes]
Client FTP support (SOAP::Transport::FTP::Client) [yes]
Standalone HTTP server (SOAP::Transport::HTTP::Daemon) [yes]
Apache/mod_perl server (SOAP::Transport::HTTP::Apache, require Apache)[no]
FastCGI server (SOAP::Transport::HTTP::FCGI, require FastCGI) [no]
POP3 server (SOAP::Transport::POP3::Server) [yes]
IO server (SOAP::Transport::IO::Server) [yes]
MQ transport support (SOAP::Transport::MQ) [no]
JABBER transport support (SOAP::Transport::JABBER) [no]
MIME messages [required for POP3, optional for HTTP]
(SOAP::MIMEParser) [no]
SSL support for TCP transport (SOAP::Transport::TCP) [no]
Compression support for HTTP transport (SOAP::Transport::HTTP) [no]
Do you want to proceed with this configuration? [yes]
In most cases, the default configuration is adequate. To indicate this to proceed with this configuration Press the Enter key to accept the default options for each of the configuration items until you get to the one that asks whether you plan to use the Jabber transport support module. Answer “yes” and press Enter. The CPAN shell will then make sure that all of the prerequisites and support modules for using Jabber are installed. You may select the default options for the remainder of the installation process.
SOAP Messages To Call The Application Code
Interprets SOAP messages to call the application code. Proxies must understand how to deal with things like coding style, the original translation of data types for XML (and vice versa), two message headers of all SOAP mustUnderstand flag = “true” is included in the law – basically.
When the proxy component for hand soap message listener, must do three things:
1. Deserialize the message, if the format is required, in accordance with the original XML to get the code.
2. Remember code.
3. Serialize the response message (if any) in XML format and back to transport listeners back to the Delivery of the applicant.
Despite differences in how SOAP implementation tasks, the tools of Web services SOAP simply follow the same pattern.
SOAP Specification Describes Encoding
SOAP specification describes encoding, which was originally developed as a service for the serialization and deserialization of data types and other sources, such as databases and programming languages. But soon came up with complications in the development of SOAP encoding and XML Schema, as well as performance. WS-I organization has a nail in the coffin of the SOAP encoding when he was the first version of WS-I Basic Profile published, saying that only the literal message XML can be used (R2706) are. The WS-I, some of the new Web Services Toolkit provides no support for the encoding of SOAP (already ubiquitous) at all.
Putting it all together, below is an example of a simple request-response in SOAP for a stock quote. Here the transport binding is HTTP.
The request:
GET /StockPrice HTTP/1.1
Host: example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:s="http://www.example.org/stock-service">
<env:Body>
<s:GetStockQuote>
<s:TickerSymbol>IBM</s:TickerSymbol>
</s:GetStockQuote>
</env:Body>
</env:Envelope>
The response:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:s="http://www.example.org/stock-service">
<env:Body>
<s:GetStockQuoteResponse>
<s:StockPrice>45.25</s:StockPrice>
</s:GetStockQuoteResponse>
</env:Body>
</env:Envelope>
If you play your cards right, you can never really see it in action a SOAP message, SOAP engine is going to do his best to hide from you, if you really want to see. If something goes wrong in your Web service can be useful to know what to look for debugging.
Much in the way that Ruby on Rails was a reaction to more complex web application architectures, the emergence of the RESTful style of web services was a reaction to the more heavy-weight SOAP-based standards. In RESTful web services, the emphasis is on simple point-to-point communication over HTTP using plain old XML (POX).
The origin of the term “REST” comes from the famous thesis from Roy Fielding describing the concept of Representative State Transfer (REST). REST is an architectural style that can be summed up as four verbs (GET, POST, PUT, and DELETE from HTTP 1.1) and the nouns, which are the resources available on the network (referenced in the URI). The verbs have the following operational equivalents:
HTTP CRUD Equivalent
==============================
GET read
POST create,update,delete
PUT create,update
DELETE delete
A service to get the details of a user called ‘dsmith’, for example, would be handled using an HTTP GET to http://example.org/users/dsmith. Deleting the user would use an HTTP DELETE, and creating a new one would mostly likely be done with a POST. The need to reference other resources would be handled using hyperlinks (the XML equivalent of HTTP’s href, which is XLinks’ xlink:href) and separate HTTP request-responses.