exposing soap as rest service in java - java

I have a vendor web service which is in SOAP but I have to write a wrapper class and expose it as Rest. Is it possible??
it will be something like client will call Rest Service but internally rest service will call Soap service.

It's certainly possible, and quite common actually. Writing middleware/glue/wrapper code is done all the time.
The approach I would take is to generate the client code using your vendors web service WSDL - for example using Axis wsdl2java. This generated code can be put into it's own lib/jar. Then write your own REST code using whatever framework you want that leverages the lib you created.
Clients would call your REST service which would internally use the lib code to connect to your vendors web service.

1)
Protocol Bridging SOA Patternis used to transform between different protocols by using a bridging broker as intermediary. The broker holds the transformation logic. bridges are available in most ESBs and EAI middle-wares.
http://soapatterns.org/design_patterns/protocol_bridging
2) Write your own logic adopter read Soap request convert in your code and expose as rest .

Related

Is the Camel Rest Component for setting up the service client or service provider?

WRT http://camel.apache.org/rest.html.
Is this component used by the client to set-up endpoint to reach an existent server?
if so, does it mean camel provides me more than one way to do it? Should I be using http component .to("http://endpointuri") instead?
What is the advantage of client using rest component over http component?
Or
used by the service provider to set-up the service provider??
if so, does this mean camel provides me more than one way to do it? Refer to http://camel.apache.org/rest-dsl.html .
What is the advantage of client using rest component over http-dsl?
1 or 2? For use by client or server? As usual, the camel docs has unspecified indirection.
This component allows Camel to expose REST services. These services will be invoked by your client. In the internal processing of a service you can do anything you want like calling other services. The DSL relies on underlying http components so you can use undertow, jetty, netty and others to set this up.
There is no such thing as a http-dsl. Essentially you use the rest-dsl together with some http framework such as undertow to expose some REST services. The DSL makes the creation of the REST services easier. I think it can also generate swagger docs for you.

Advice on implementing JAX-WS web services to be consumed by non-Java (PHP) endpoint

I am a Java SE programmer and exploring implementing JAX-WS web services for the purpose of integrating with our web server. To this date, I have not had experience with web-services thus would like to get everyone’s expert opinion.
The background is that my company has a POS system developed and hosted in-house using Java SE. We are planning for e-commerce capabilities, which will be implemented in HTML/PHP, via external web development company and hosted externally.
Thus we are exploring implementing JAX-WS web services on our endpoint for the purpose of integrating with our e-commerce server running PHP endpoint.
I’ve done some research and my understanding is that:
it is possible to implement JAX-WS without Java EE containers
JAX-WS Web Services Without Java EE Containers
it is possible to mix end-point technologies, and specifically in my case JAX-WS as our endpoint and PHP SoapClient on our e-commerece end-point
PHP SOAP Client to consume JAX-WS with Basic Http Authentication
Using PHP SoapClient with Java JAX-WS RI (Webservice)
I am now wondering what’s is the proper approach when discussing implementation with the external web development company that is building our e-commerce platform. Most web sites and forums’ examples assumes Java on both endpoints and that both endpoints are implemented by the same developer/team.
Based on my limited understudying, I gather the process would be:
Me/my company creating the web service (coding the web services methods in Java)
Me/my company creating the server program
The wsdl generated from the URI (http://:/md5WebService?wsdl )of my server program is then used as the interface contract between our internal POS system and the external e-commerce platform
The web development company that is implementing the e-commerce platform then uses the wsdl to implement the PHP SoapClient endpoint on their side.
And in the case where our internal POS system need to consume a web services created by the external web development company, they will pass me the wsdl and I use that to make the call to them.
Is this the correct way to do proceed?
Many thanks.
Cheers,
Arthur
In Java you have actually two ways to start your design of your web service. You can either create the WSDL (Web Service Description Language) contract first (contract first approach) and then let Java or some framework tools create Java skeleton classes for you which you can use to implement the logic of each operation or you can start by code first approach and implement each web method and its logic and then let Java or some external framework tools generate the WSDL contract for you.
Either way you start, the result should be very similar and platform independent. The standard message format used for WSDL based web services is SOAP (Simple Object Access Protocol) which is based on XML (eXtensible Markup Language) which is by definition platform and programming language neutral.
So, after implementing your service and starting a server for the WS endpoint adding ?wsdl to the end of the endpoint URL should return the WSDL contract to the invoker, which can be used to create client side stubs for the required programming language which furthermore simplify the sending and receiving of messages from and to the web service. Note however that creating stub files might not be needed as all the information may be parsed from the WSDL contract directly. As of lack of knowledge concerning PHP I can't give details on how to call a WS from PHP directly or if stub file creation is required/recommended.
In order to call an other WS from your service you need to create a WS client within one of your web methods and invoke one or more of the operations offered by the remote WS and process the response within your web method.
As I am not sure if you are using any (Java) frameworks like f.e. Apache CXF I am not giving any code examples here. For integrating external web services within your service you might also have a look at Apache Camel which offers integration support for numerous Java based frameworks including CXF. Here your web service is treated as a Consumer while other external services you need to invoke are handled as Producers. The interaction between your internal and the external services is modeled here within a route where you can apply various Enterprise Integration Patterns (EIP) like splitting multiple elements contained within a response into distinct objects which you furthermore can process in parallel.
In general your enumeration of steps involved does look right if you follow the code first approach but as mentioned earlier you can also start by defining your contract first. Depending on your knowledge of the WSDL/XSD syntax (the less you know the exact syntax the more you should use code first approach), crating the contract first might enable PHP side integration sooner while you still develop the internal logic of your implementation.
it is possible to mix end-point technologies, and specifically in my case JAX-WS as our endpoint and PHP SoapClient on our e-commerece end-point PHP SOAP Client to consume JAX-WS with Basic Http Authentication Using PHP SoapClient with Java JAX-WS RI (Webservice)
This is the exact purpose of introducing webservice concept. You don't have to worry about on which platform or language your client and server is implemented. Client and server will simply exchange xml messages (platform independent) as agreed upon within wsdl.
Go ahead with your understanding.

What are the steps needed for accessing a WCF service from a non .NET clients(ex.JAVA,HTML5)?

I want to create a WCF service which is to be accessed by a non .NET client. Apart from REST based methodology is there any steps involved in exposing the service to other client like JAVA,HTML5,Android etc., Help me out.
Consuming a WCF Service from non .NET clients should be the same as consuming it from a .NET Client. You would need the wsdl to generate a client side proxy and use the proxy to access the WCF Service.
The WCF Service might have various security features for securing it and your client needs to adher to them to get a proper access and response back from the service.
Few things you might encounter when accessing from non .NET Clients is that the WCF service doesnt have a Flat Wsdl. In such cases it becomes a bit difficult to access it. If you are planning to develop a WCF Service for non .NET Clients i would suggest you to make sure that you have Flat Wsdl. Also it would be better off to adher to Basic Profile 1.1 for your WCF service to be interoperable and try using BasicHttpBinding to avoid many road blocks when accessing from non .NET Clients (saying that make sure your service is properly secured)
Flat Wsdl -> It means that your Wsdl should not have any import elements in it to reference external xsd's etc..
Once you have the WCF Service written try to invoke it from some tools like Fiddler, SOAP UI to make sure that you would not have problems when non.NET clients access them.
If you are on .NET 3.5 then have a look at this link.
Going ahead in .NET 4.5 you have a new option in built into the framework to generate a Flat wsdl. Look at this link.

ESB webservice adaptor

Does the webservice adaptor's function is let different webservice(eg,http/jms) can call each other?Does it like a proxy such as transform soap/http webservice to soap/jms webservice?
enter link description here
In the picture there exist three webservice,webservice-1 and webservice-1 are published by third part,adaptor-A and adaptor-B are used to call them,webservice-3 is published by adaptor-c.first,when someone call webservice-3,the adaptor-c intercept the soap request and send it to esb ,the esb have a broadcast router and the router send it to adaptor-A & adaptor-B,adaptor-A & adaptor-B then analyse the message and call webservice-1&webservice-2.after that adaptor-A & adaptor-B send webservice response to esb,esb also have a aggregator in it,then aggregator assemble these two response and send it to adaptor-c,At last,adaptor-c send the final result to webservice-3 user!
I want to if this flow is feasible?if feasible,how to design the adaptor-A and adaptor-B and adaptor-c?
yes, this is well suited scenario for an ESB. When your adapters don't implement a special business logic and are only responsible for "speaking" the protocol expected by the Web service, you can probably connect the services directly to the ESB. This kind of "protocol virtualization" is basically provided by all kinds of ESBs, even plain Web service stacks like Axis2 or CXF can deal with a large set of transport protocols.
Regarding the business logic there are different possibilities. For simple scenarios you can consider using a EIP-aware framework like Apache Camel and chain Enterprise Integration Patters (EIP) [Hohpe et al] to achieve the desired integration. For more complex scenarios you can consider using BPEL (Business Process Execution Language). BPEL is descriptive parallel programming language with focus on orchestrating Web services in a transactional, long-running fashion. BPEL can be executed e.g. by Apache ODE.

WCF web service and java web service

Can web service developed in Java can be consumed by WCF web service and vice versa.??
Yes, Web Services are basically request/response calls through a network. The message is XML. This protocol is known as SOAP (Simple Object Access Protocol). So, you're passing XML data across the wire. WCF wouldn't care less which originating language it comes from as it only sees XML.
Alternatively, you can use HTTP request/response using REST.
Yes they can, if you run into trouble and are using SOAP it will most likely be due to versions in the security headers. If so you WCF can be configured to use custom binding (Sure the same applies for java side). Rest is simpler.
Checkout http://www.soapui.org/. It is written in java and can communicate using both Rest and Soap.

Categories