|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS FrontPage Feature Constructing Services with SOA & Open Source Java
The Jedi mind trick is a Force power that can influence the actions of weak-minded sentient beings
By: Franz Garsombke
May. 9, 2007 08:30 PM
Typically, a real-world application will have a database running for these Hibernate tools tasks to reverse-engineer against. The example code uses a HSQL database engine to simulate this behavior. The source code to start-up, create, and populate the database can be found in the example application. The data access service is defined in our Spring context file in Listing 4. The database consists of one table called ANDROID that's mapped to a Java class called Android. The generated data access object can then be used in our data access provisioning service: public class ProvisioningDaoImpl extends AbstractDao implements ProvisioningDao { The configuration needed for Hibernate is performed behind the scenes using Spring. WSDL-First, You Must Do WSDL-first development is the concept of writing the interface for your Web Service before you write the code. WSDL-first development makes sense because it focuses less on a particular programming language and more on the messages between systems. Many people take the approach of generating the WSDL from existing code whether it's an EJB, POJO, or some other programming construct. WSDL-first takes a more top-down approach wherein the schema and WSDL are designed first and code generation happens from there. XML Schema is language-independent and provides more flexibility than a lot of programming languages. Client code, interfaces, implementation code, and schema types can all be generated from a WSDL and schema by a number of SOAP stack frameworks. One of the main benefits of WSDL-first development is improving interoperability between disparate systems programmed in different languages. Taking our top-down approach let's look at an operation defined on our WSDL: <wsdl:operation name="findDroid"> The document/literal approach to constructing a Web Service is more straightforward and solves many interoperability issues since it simply relies on XML Schema to describe exactly what the message looks like when delivered. Also, document/literal is WS-I (Web Services Interoperability) compliant. The request and response messages are defined below: <xs:element name="findDroid" type="provisioning:findDroid"/> By using a combination of XMLBeans (one of the many XML binding mechanisms supported by XFire), XFire, and our WSDL we can use separate tasks in Maven to generate everything needed to build a Web Service. There's an execution step defined in our maven-antrun-plugin in Listing 5. All of the Web Service code generation is done in the generate-sources phase of the Maven build lifecycle. This lets us generate all of the messaging objects we rely on before our implementation code needs to compile against them. Since all of our messaging objects have been generated we can now implement our provisioning Web Service. XFire creates an implementation class based on the WSDL provided. That same class will be used to implement all of the business logic needed by our system. The provisioning service is injected with the core service and data access service defined and implemented in earlier modules. The code in Listing 6 shows the provisioning service using the two services it's dependent on to look up android information. The only thing left to do is wire up our provisioning Web Service. An important thing to note is that the provisioning service is a POJO. We could easily inject it into a different transport protocol implementation. XFire is used in this instance. We define our provisioning service as a service bean in XFire's service factory and are off and running. <serviceFactory>org.codehaus.xfire.xmlbeans.XmlBeansServiceFactory</serviceFactory> XFire takes care of the Web servlet, marshaling/unmarshaling of the SOAP messages, and determining which service and which operation needs to be executed. If our requirements dictate that we need a composite service comprised of the provisioning service and some other service we could just create a higher-level module and inject the services that have already been built. The provisioning service would then be just a POJO as opposed to a formal Web Service. Empire Building The Saga Continues Acknowledgements References
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||