Creating A Basic Web Service
In this post, I'm going to go through how to create a simple web service using eInsight in Java CAPS.
This will be a precursor for Correlation which will be discussed later.
XML Schema Definitions
The first step in designing a basic web service is to determine its input's and outputs. In this case, we are going to have one input which will double as an output.
The fields it will have are
Message ID : The message ID of the message received from the external system.
Date : A Date field to contain the date
Payload : A Payload field to contain free text.
This isn't a very complex message and is pretty generic, this suits my current purposes. I will in a later post go through data analysis and message structure design principles in a later post.
So, Step 1 is to create your xsd to contain the required fields.
Log into Java CAPS, Create a new project and I like placing my xsd's into a sub directory called "xsd".
Right click the xsd project and select "New" then "XML Schema Definition".
Rename the new XML Schema definition to "xsdMessage".
Now its time to add the elements and fields to the XSD.
Right click "xsdMessage" and select "Add" then "Element".
I renamed the element to Message.
Right click "Message element and select "Complex Type".
Add a sequence...
Finally, add the elements for the message....
MessageID : xsd:String
Date : xsdDate
Payload : xsdString
Creating the Web Service Definition
The next step is to incorporate the xsd into a WSDL.
Right click the "xsd" project and select, "New" then "Web Service Definition" and give the new definition the name "wsMessage".
On the Web Service Definition page, right click Import and Select "Import WSDL, XSD or OTD" to import the xsd created earlier.
Add xsdMessage in the Dialog box that comes up and click OK.
In the WSDL Document, right click "Message" and add a new Message. Rename it "msgMessage"
In the "Add Parts" Dialog box, select the "Elements Tab" and then add the "ns0:Message" type. This is the message type we created earlier.
In this pic, the Message type has been added to the "Selected Types"
We now have a new Message Type of "Value1". If you like, you can rename it, but I'm going to leave it alone for this purpose.
Next, we have to create an operation. There is one operation created by default, so I'm going to use it. You can rename the operation by rightclicking and selecting rename, but I'm feeling lazy today so I'm going to leave the name as is.
Here you can add an Input, Output and Fault message. I'm just going to add Input and Output messages.
After adding the Input and Output message, Change the "Message Type" to "tns:msgMessage" which is the message you created earlier.
For this implementation, the input and output messages are going to be the same, but they don't have to be.
Save your WSDL. We're now ready to put some functionality behind it.
Creating the Business Process
In this tutorial, I'm going to be using eInsight to create the business rules behind the Web Service.
So, Right click your project and select "New" then "Business Process"
You will see a new canvas come up on the right hand side.
Drag and srop your Web Service Operation onto this canvas.
You will be asked if this is to be "Server Mode" or "Client Mode".
Server Mode : Means that you are "Hosting" the service and performing the underlying functionality to it.
Client Mode : Means you are "Calling" the service.
In our case, we are going to host the service, so select "Server Mode".
You will now see the "Receive" and "Reply" stubs on the canvas.
This is going to be a simple web service. For this, we only need one business rule, but the functionality can be as simple or as complex.
Drag a "business rule" onto the canvas.
And Link up all the components.
Adding the Business Rules
Now, double click the business rule on the canval, This will bring up the editor for the business rule functionality.
The business rule functionality for this web service will be simple, its going to take the payload and put it withing "Hello World []".
There are a number of operations that can be performed in a business rule, but for more complex functionality, its best to implement these in Java.
Remember, BPEL is an "ORCHESTRATION" language, not a fully functional language like Java.
Below is the full code for our web service.
Copy across MessageID and Date to their corresponding Input Parameters, and save the business process.
Save your business processes.
Now lets get set to deploy everything.
Create the Connectivity Map
Right click on the project and select "New" then "Connectivity Map"
Drag your Business Process onto the canvas and double click it to open it up. Also drag across the "Web Service External Application" component
Connect the "Port Type" otd in the CMap1_bpWebService1 service to the "Web Service Application1" component then save your connectivity map.
Build and Deploy.
Build and deploy your web service project. During deployment, you will be asked whether you want to deploy the WSDL to a UDDI Registry or a Jar file. If you have the Sun/SeeBeyond UDDI registry installed and running, select this or if you wish to have the WSDL registered in a third party UDDI Registry, export to a .jar file.
Use the UDDI registry or Jar file to extract the URL for the web service. You can now use this URL to access the web service.
Your web service is now ready for use.
The Final Result
I like to use an open source product called "soapUI" for my testing. Its a simple product and gives me access to the raw soap message.
There are other third party products available, whichever your feel the most comfortable with is the one you should use.
Now, using soapUI, here is the results from our web service.
SOAP Header (From SoapUI)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://TM5-HPaffrath:12000/repository/HJP_JCAPS512/xsd/Correlation/HJP_JCAPS512112ce48:116c1d23c96:-7fff/XSDDefinition1">
<soapenv:Header/>
<soapenv:Body>
<xsd:Message>
<MessageID>12345</MessageID>
<Date>2007-12-11</Date>
<Payload>Test Data</Payload>
</xsd:Message>
</soapenv:Body>
</soapenv:Envelope>
Result
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://TM5-HPaffrath:12000/repository/HJP_JCAPS512/xsd/Correlation/HJP_JCAPS512112ce48:116c1d23c96:-7fff/XSDDefinition1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<ns0:Message xmlns:tns="http://TM5-HPaffrath:12000/repository/HJP_JCAPS512/xsd/Correlation/HJP_JCAPS512112ce48:116c1d23c96:-7fff/XSDDefinition1">
<MessageID>12345</MessageID>
<Date>2007-12-11</Date>
<Payload>Hello World [Test Data]</Payload>
</ns0:Message>
</env:Body>
</env:Envelope>
Summary
This is just one of the many ways to create a web service in Java CAPS. In my next tutorial I will use this as a foundation for implementing Correlation.
If all the images come out in this post, it seems that Zoundry is a great offline editor to use, although if you know of something better, please let me know.
I hope these tutorials are useful. As mentioned before, the next one will use this as the basis for Correlation.
Finally,
Its getting late in the year, and if this is my last post before Christmas, I would like to with everyone a Merry Christmas and a Happy New Year :-)
And one more thing after all this, Zoundry didn't work with the pictures, so I'm still on the lookout for a better offline blog editor. If you know of one that's really good (and free) let me know.
Merry Christmas :-)
Posted at 07:09AM Dec 16, 2007 by Holger Paffrath in Sun | Comments[7]

Hi Holger,
Thanks for taking time to post these nice tutorials which would inturn help in creating a rich knowledge based commnunity on java CAPS.
Reg. the blog editor, I was using the firefox addon 'ScribeFire' to post to my blog. I was able to post blogs with pictures embedded in them.
I was working with seebeyond ICAN for some months now and I believe that egate integrator has a lot of inbuilt methods.
Is there any way to get a javadoc of all the methods present in egate?
Inyour post you have mentioned that BPEL is just a ORCHESTRATION language and not a fully qualified language as Java. There are some operations which can be performed in BPEL and also in JCD. Is there any guidelines available to know about which one to use in BPEL and JCD?
Thanks a lot for you time.
Merry Christmas!!!!
Posted by Sivaraman V on December 18, 2007 at 04:58 AM EST #
Thanks for your support Sivaraman.
I'll give ScribeFire a go see how I go.
As for the inbuilt methods in ICAN, most of them are not available in Javadocs unfortunately. For those that are, the javadoc should be downloadable from the downloads tab in the Enterprise manager (Where you download the Enterprise Designer, Samples etc - Can't remember exactly, haven't used ICAN for a while now)
For example, there is one for the Batch eWay. I think there is a way to get it within the Enterprise designer, but I can't remember how off the top of my head.
As for BPEL, it is true that some operations are available for both Java and BPEL, and in some cases you can use both, but I have 2 guidelines for using BPEL. Firstly, If its business related - use BPEL, if its Technical, use Java. Secondly, Keep it simple. If your BPEL is starting to get large and difficult to manage, then look at separating the functionality to smaller modules, or if its easier to implement the functionality in Java, then do so.
Hope this helps.
Merry Christmas
Posted by Holger Paffrath on December 18, 2007 at 10:24 AM EST #
nai
Posted by 122.217.195.43 on January 07, 2008 at 10:33 PM EST #
Hi Holger,
thanks for your work!
I've to create a simple web service and I'd like to reuse a JCD that I developed for another project, because it contains the logic that I need.
I tried to put the JCD directly between Receive and Reply elements, without using a Business Rule, but this solution generates the follow error:
[#|2008-06-09T19:22:18.016+0200|FINE|IS5.1.3|com.stc.wsserver.runtime.impl.LoggingHandler|_ThreadID=20; ThreadName=http18001-Processor4;|<<ICAN Server>> SOAP Response is : <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:stc:egate:jce:JavaException" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Body><env:Fault><faultcode>env:Server</faultcode><faultstring>Internal server runtime exception</faultstring><detail><ans1:SOAPFaultMessage xmlns="http://seebeyond/com/xsddefined/FaultMessages" xmlns:ans1="http://seebeyond/com/xsddefined/FaultMessages"><ans1:Fault><ans1:faultcode>com.stc.bpms.bpel.BPELException</ans1:faultcode><ans1:faultstring>BPELException: faultCode=OTHER_ERROR: (null)object is created for MessageType: {urn:stc:egate:jce:prjHL725_Common_XSDNodes_jcdWS_ADTEventNotification}Input</ans1:faultstring><ans1:faultactor>Runtime</ans1:faultactor><ans1:detail>Message:
BPELException: faultCode=OTHER_ERROR: (null)object is created for MessageType: {urn:stc:egate:jce:prjHL725_Common_XSDNodes_jcdWS_ADTEventNotification}Input
Stack:
com.stc.bpms.bpel.BPELException: BPELException: faultCode=OTHER_ERROR: (null)object is created for MessageType: {urn:stc:egate:jce:prjHL725_Common_XSDNodes_jcdWS_ADTEventNotification}Input
at com.stc.bpms.bpelConnector.impl.WSMessageFactoryImpl.transformToWSMessage(WSMessageFactoryImpl.java:170)
at com.stc.bpms.bpelConnector.impl.WSMessageFactoryImpl.createMessage(WSMessageFactoryImpl.java:108)
at com.stc.bpms.bpelImpl.runtime.CallFrame.createContainerData(CallFrame.java:1835)
at com.stc.bpms.bpelImpl.runtime.Interpreter.invoke(Interpreter.java:592)
at com.stc.bpms.bpelImpl.runtime.Interpreter.interpret0(Interpreter.java:458)
at com.stc.bpms.bpelImpl.runtime.Interpreter.interpret(Interpreter.java:179)
at com.stc.bpms.bpelImpl.runtime.BPELInterpreter$1.run(BPELInterpreter.java:319)
at com.stc.bpms.bpelConnector.impl.ExecutorImpl$WorkImpl.run(ExecutorImpl.java:338)
at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:54)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:382)
</ans1:detail></ans1:Fault></ans1:SOAPFaultMessage></detail></env:Fault></env:Body></env:Envelope>|#]
I don't understand if the Business Rule is a mandatory element to create a Web Service, or if the flow "Receive-JCD-Reply" is enough... can you help me?
Posted by Fabrizio on June 10, 2008 at 06:25 PM EST #
Hi Fabrizio,
You do need to put in the business rules. These map the WSDL message structure to the input and output message structure to the JCD. This mapping is not done automatically.
If the mapping is not present, then a null message is sent to the jcd. This is fine if you want to trigger the JCD but not use any data from the Web Service call.
As for the outbound, if no mapping is present from the JCD outbound to the SOAP message, then you get the above error. In your case, the business rule is mandatory as you have requested an output, but have not set the mapping of the output from the jcd to the SOAP message format in the business rule.
Posted by Holger on July 15, 2008 at 09:12 AM EST #
Hi, we developed a Web Service layer server from jcd collaboration. Now we have to set basic environment parameters like timeout or MaxClients (maximum number of simultaneous connections to our Service).
Does it exists any Web Service Administration Console or configuration file on Jcaps 5.1.2 where we can set this?
Posted by TeamEai on October 01, 2009 at 02:06 AM EST #
Hi TeamEAI,
Unfortunately as far as I know, those settings cannot be specified in Java CAPS
5.1.2 through a JCD exposed as a web service.
If you need more detailed functionality, you may need to look at using apache
axis or JAX-WS within your jcd.
Posted by Holger Paffrath on October 29, 2009 at 02:01 PM EST #