home / infca / MB_WSRVC (navigation links) A "web service" is ...

Def | Hello my friend Libros | Links | End

Web Services


Definicions

What is a Web Service ? : The W3C defines a Web Service as a software system designed to support interoperable machine to machine interaction over a network. Web services are frequently just API's that can be accessed over a network, and executed on a remote system hosting the requested services.

Among the many ways devised to enable humans to use software running on distant computers, HTML transported over HTTP and presented via a web browser is surely the most successful yet.

Wiki

The most significant web services technologies address three questions:

Getting started with Web services

What is a Web service? A Web service is a program that understands SOAP (XML+Rich Content).
A Web service is described by a WSDL definition. WSDL defines the name and location of the service and its interface.
SOAP consists of a standard XML message wrapper (called Envelope) that embeds payload data within Header and Body elements.

The broker usually isn't the right place to implement a Web service from scratch, but the strength of the broker is that it can support reuse by:

URL [*****]

Vocabulary

SOAP
An XML-based, extensible message envelope format with "bindings" to underlying protocols. The primary protocols are HTTP and HTTPS.

Web Services Description Language (WSDL)
An XML format that allows service interfaces to be described along with the details of their bindings to specific protocols. Typically used to generate server and client code, and for configuration.

Universal Description Discovery and Integration (UDDI)
A protocol for publishing and discovering metadata about Web services that enables applications to find them, either at design time or runtime.

Styles of use
Web services are a set of tools that can be used in a number of ways. The three most common styles of use are RPC, SOA and REST.

Web services can also be used to implement an architecture according to Service-oriented architecture (SOA) concepts, where the basic unit of communication is a message, rather than an operation. This is often referred to as "message-oriented" services.

legacy APP goes web-service

In this scenario, the broker implements a new Web service interface.
An existing message flow is modified to provide a Web service. If the existing message flow models its data in a message set, a WSDL definition can be generated from that message set and made available to clients.

publib

how to get a web-service WSDL file

Querying WSDL with ?wsdl

How to create a WSDL ?
Resum

Un client d'un web-service és un programa que parla HTTP per enviar un stream XML a una IP+port. XSD can be used to express a set of rules to which an XML document must conform in order to be considered 'valid' according to that schema. wiki. You can validate XML against XSD : libxml2.


Amunt! Top Amunt!
Toolkit nodes

SOAPinput & SOAPreply

See "MB v 6.1 Message Flows" book ! [16.448.996 chars]

See & Run Toolkit samples !

See Toolkit Help !


Amunt! Top Amunt!
Lets implement a WebService

What can it do ?

WS in toolkit samples
ws host

Demostrates how to use a broker to provide an interface to a legacy application as a web service.
See mb_tkt.htm also and \\T430\IIBv9\workspace
In Toolkit, find "Web Services using HTTP nodes sample" and deploy it. Then,

  1. start legacy application : runLegacyApp.bat from WSHOST_LEGACY1 folder - verify MQCONN() and MQOPEN() are ok
  2. send a message - send WSHOST1IN.xml file to http://localhost:7080/samplebrokerwshost using \\T430\WebService\MB\host\envia.cmd
    set FN=WSHOST1IN.xml set URL=http://localhost:7080/samplebrokerwshost "c:\Program Files (x86)\GnuWin32\bin\wget.exe" "%URL%" --post-file="%FN%" --header="Content-Type:text/xml"

    Its contents is:

    <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/ xmlns:c="http://www.brokersamplewshost.ibm.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <c:IA81CONFIN> <MessageId>IA81CONF</MessageId> <OrderNumber>ON4002</OrderNumber> <ItemReference>IY4003</ItemReference> <ItemQuantity>4</ItemQuantity> <CustomerNumber>CY4004</CustomerNumber> <DeliveryRef> </DeliveryRef> <Confirm> </Confirm> <filler1> </filler1> </c:IA81CONFIN> </soapenv:Body> </soapenv:Envelope>

    We receive back

    type samplebrokerwshost <?xml version="1.0"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://www.brokersamplewshost.ibm.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <tns:IA81CONFOUT> <MessageId>IA81CONF</MessageId> <OrderNumber>ON4002</OrderNumber> <ItemReference>IY4003</ItemReference> <ItemQuantity>4</ItemQuantity> <CustomerNumber>CY4004</CustomerNumber> <DeliveryRef>JOHNCORP</DeliveryRef> <Confirm>Y</Confirm> <filler1> </filler1> </tns:IA81CONFOUT> </soapenv:Body> </soapenv:Envelope>
  3. you can get WSDL file from http://localhost:7080/samplebrokerwshost?WSDL
MB as a ws client
MBclient

Scenario

Assume that you want the broker to invoke an existing web service. You import a WSDL definition for the web service to create a message set and create a message flow to invoke the web service. If the Web service transport is HTTP, then you would use an HTTPRequest node. At run time, your message flow creates an appropriately formatted web service request, invokes the web service, and parses the web service response

Possible uses

src

web services client Demonstrates how to call a web service, and how to process the reply from the Web service.

From MB toolkit samples : "web services using HTTP nodes - run web service client"
Own code : \\T430\WebService\MB\legacy

 

  1. start legacy application : runLegacyApp.bat - verify MQCONN() and MQOPEN() are ok
  2. send a message : click WSCLIENT1.mbtest - "message flow test" window opens - click "enqueue", then "dequeue"

Sample input message is in "WSCLIENTIN.dat" and contains

IA81BUY LAB51234ITEM12345678qty00005CUST34567890zzzzzzzz 1234567812345678123456789abc12345678123456789abc12345678

It is based on the following format:

typedef struct tagIA81BUY { char MessageId[8]; char OrderNumber[8]; char ItemReference[12]; char ItemQuantity[8]; char CustomerNumber[12]; char DeliveryRef[8]; } IA81BUY;

Convert MQ to SOAP :

BROKER SCHEMA WSCLIENT_MFP1 DECLARE ns NAMESPACE 'http://www.brokersamplewshost.ibm.com'; DECLARE tns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/'; CREATE COMPUTE MODULE WSCLIENT_WSCLIENT1_Compute CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN CALL CopyMessageHeaders(); -- Save the MQMD; sending to HTTP later in the flow destroys it SET Environment.MQMD = InputRoot.MQMD; -- Input is CWF, Ouptut is SOAP, so set the wire format and message name SET OutputRoot.Properties.MessageType = 'Envelope'; SET OutputRoot.Properties.MessageFormat = 'XML1'; -- Build message to be sent to web service SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.MessageId = 'IA81CONF'; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.OrderNumber = InputBody.OrderNumber; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.ItemReference = InputBody.ItemReference; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.ItemQuantity = InputBody.ItemQuantity; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.CustomerNumber = InputBody.CustomerNumber; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.DeliveryRef = ' '; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.Confirm = ' '; SET OutputRoot.MRM.tns:Body.ns:IA81CONFIN.filler1 = ' '; RETURN TRUE; END;

Convert response from XML to MQ :

CREATE COMPUTE MODULE WSCLIENT_WSCLIENT1_Compute1 CREATE FUNCTION Main() RETURNS BOOLEAN BEGIN CALL CopyMessageHeaders(); -- Output is MQ, so remove HTTP headers SET OutputRoot.HTTPResponseHeader = NULL; -- Output is CWF, so set target message properties SET OutputRoot.Properties.MessageType = 'msg_tagIA81CONF'; SET OutputRoot.Properties.MessageFormat = 'CWF1'; -- Create an MQMD and restore it to saved values CREATE NEXTSIBLING OF OutputRoot.Properties DOMAIN 'MQMD'; SET OutputRoot.MQMD = Environment.MQMD; -- Build message to be sent SET OutputRoot.MRM.MessageId = InputBody.tns:Body.ns:IA81CONFOUT.MessageId; SET OutputRoot.MRM.OrderNumber = InputBody.tns:Body.ns:IA81CONFOUT.OrderNumber; SET OutputRoot.MRM.ItemReference = InputBody.tns:Body.ns:IA81CONFOUT.ItemReference; SET OutputRoot.MRM.ItemQuantity = InputBody.tns:Body.ns:IA81CONFOUT.ItemQuantity; SET OutputRoot.MRM.CustomerNumber = InputBody.tns:Body.ns:IA81CONFOUT.CustomerNumber; SET OutputRoot.MRM.DeliveryRef = InputBody.tns:Body.ns:IA81CONFOUT.DeliveryRef; SET OutputRoot.MRM.Confirm = InputBody.tns:Body.ns:IA81CONFOUT.Confirm; SET OutputRoot.MRM.filler1 = InputBody.tns:Body.ns:IA81CONFOUT.filler1; RETURN TRUE; END;
my first WS

Trying to find an easy one

Hello my friend (using Eclipse)

part 1

Maybe part 2 has the answer ? No - Jose Angel Flores had the solution :

2nd WS : Time Of Day

On Eclipse we code another web service :

package com.ws.tod; import java.text.SimpleDateFormat; import java.util.Calendar; import javax.jws.WebService; @WebService public class sayTOD { private static final String SALUTATION = "TOD server." ; public String say_TOD ( String name ) { long timeInMillis = System.currentTimeMillis(); Calendar mycal = Calendar.getInstance(); mycal.setTimeInMillis(timeInMillis); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a"); String mydate = dateFormat.format( mycal.getTime() ) ; return SALUTATION + " " + name + ", now its {" + mydate + "}." ; } }

We run it as before, as Java Application, and send this XML:

<soapenv:Envelope xmlns:q0="http://tod.ws.com/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> </soapenv:Header> <soapenv:Body> <q0:say_TOD> <arg0>pepeta</arg0> </q0:say_TOD> </soapenv:Body> </soapenv:Envelope>

To receive this beautiful answer:

<?xml version="1.0" ?> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body><ns2:say_TODResponse xmlns:ns2="http://tod.ws.com/"> <return>TOD server. pepeta, now its {31/03/2014 12:15:55 PM}.</return> </ns2:say_TODResponse></S:Body></S:Envelope>
stock quote WS

Full description here : https://www.ibm.com/developerworks/library/ws-apacheaxis/ : Axis, ant, Tomcat, Jawa2WSDL, TCP/IP monitor in Eclipse,

Get Axis and ant

We shall create a "Java project in Eclipse"

MQ related WS

To use all my MQ tools, I can use

. --- convert legacy to web service --- . --- old mq server app | HTTP input ---> Compute -------------> | MQ input ---> | Compute HTTP output <--- Compute <------------- | MQ output <---

Amunt! Top Amunt!
How to send an XML to a web service

google + how to send a xml to a web service : url


Eclipse TCPIP monitor

If we want to see the HTTP message sent to a web service we can use TCPIP monitor included in Eclipse. If web service was listening on port 8181, we shall


VM curs WAS

You can use a Java bean that already exists and then enable the implementation for Web services. Enabling the Java bean for Web services includes developing the service endpoint interface, developing a WSDL file that is the engine of the Web service, generating and configuring the deployment descriptors, assembling all artifacts required for the Web service, and deploying the application into the WebSphere Application Server environment.

1. Create a temporary subdirectory : *. C:\> mkdir \temp 2. Extract the war file to the temporary subdirectory : *. C:\> cd \temp *. C:\temp> C:\WAS6\AppServer\java\bin\jar -xvf "C:\WAS60STEW\hands-on\1.6WebServicesLab\JavaBean.war" 3. Copy the service endpoint interface into the source subdirectory. *. C:\> copy "C:\WAS60STEW\hands-on\1.6WebServicesLab\CheckCreditBean_SEI.java" C:\temp\WEB-INF\source\com\creditcheckcorp\jb 4. Compile the service endpoint interface. *. C:\temp> cd C:\temp\WEB-INF\source\com\creditcheckcorp\jb *. C:\temp\WEB-INF\source\com\creditcheckcorp\jb> C:\WAS6\AppServer\java\bin\javac -d C:\temp\WEB-INF\classes CheckCreditBean_SEI.java This will create a C:\temp\WEB-INF\classes\com\creditcheckcorp\jb\CheckCreditBean_SEI.class file. 5. Develop a WSDL file. *. C:\temp\WEB-INF\source\com\creditcheckcorp\jb>cd C:\temp\WEB-INF\classes *. C:\temp\WEB-INF\classes>C:\WAS6\AppServer\bin\java2wsdl -implClass com.creditcheckcorp.jb.CheckCreditBean -location http://localhost:9080/JavaBean/services/CheckCreditBean com.creditcheckcorp.jb.CheckCreditBean_SEI This will create a CheckCreditBean.wsdl file in the current directory. 6. Move the WSDL file into the WEB-INF/wsdl subdirectory. *. C:\temp\WEB-INF\classes> mkdir C:\temp\WEB-INF\wsdl *. C:\temp\WEB-INF\classes> move CheckCreditBean.wsdl C:\temp\WEB-INF\wsdl 7. Develop Web services deployment descriptor templates for a JavaBeans implementation. *. C:\temp\WEB-INF\classes> cd C:\temp *. C:\temp> C:\WAS6\AppServer\bin\wsdl2java -verbose -role server -container web -introspect -genJava no WEB-INF\wsdl\CheckCreditBean.wsdl 8. Assemble the Web archive file. *. C:\temp> C:\WAS6\AppServer\java\bin\jar cvf JavaBean.war . 9. Bring up ASTK to complete the packaging and to generate an EAR file. 10. Start the application server. *. C:\> cd WAS6\AppServer\profiles\AppSvr01\bin *. C:\WAS6\AppServer\profiles\AppSvr01\bin> startServer server1 *. C:\WAS6\AppServer\profiles\AppSvr01\bin> serverStatus server1 11. Open the administration console : *. Launch a Web browser and open http://localhost:<admin_port>/admin The default admin port is 9060. To know what TCP port the administration console is using, open the file C:\WAS6\AppServer\profiles\AppSrv01\logs\portdef.props *. Enter a User ID and select the "Log in" button. 12. Select "Applications", then "Install New Application". 13. Specify the JavaBeanEAR.ear module : *. Select "Browse.". *. Navigate to the C:\WAS60STEW\hands-on\1.6WebServicesLab directory containing the JavaBeanEAR.ear file. *. Select the JavaBeanEAR.ear file. *. Select the "Open" button. 14. Select the "Next" button. 15. Select the "Next" button. 16. Select the "Step 4" URL. 17. Select the "Finish" button. 18. You should see a "Application JavaBeanEAR installed successfully." message. Select the "Save to Master Configuration" URL. 19. Select the "Save" button. 20. Select "Applications", then "Enterprise Applications". 21. Check the JavaBeanEAR box, then select the "Start" button. 22. The JavaBeanEAR application should be started.

*** You have created a Web service from a JavaBean ***

Verify the Web service

Deploy JavaBeanClientEAR.ear and start JavaBeanClientEAR 35. Test the Web service from your browser with the following URL: http://localhost:9080/JavaBeanClient/sampleCheckCreditBeanProxy/TestClient.jsp 36. Select the "search(java.lang.String)" method. 37. Input the value "1234" into the SSN text box, then select the "Invoke" button.

Install a UDDI V3 Private Registry

1. Ensure that the application server is not running. __ a. C:\> cd c:\WAS6\AppServer\profiles\AppSvr01\bin __ b. C:\WAS6\AppServer\profiles\AppSvr01\bin> stopServer server1 __ c. C:\WAS6\AppServer\profiles\AppSvr01\bin> serverStatus server1 2. Deploy UDDI to a standalone server. __ a. cd c:\WAS6\AppServer\bin __ b. wsadmin -conntype none -wsadmin_classpath c:\WAS6\AppServer\cloudscape\lib -f uddiDeploy.jacl Node01 server1 default > uddiDeploy.log -- c. Edit the uddiDeploy.log file to verify a successful completion. -- d. Verify that the Cloudscape database has been created at the following subdirectory: C:\WAS6\AppServer\profiles\AppSvr01\databases\com.ibm.uddi\UDDI30 3. Start the application server. __ a. C:\> cd c:\WAS6\AppServer\profiles\AppSvr01\bin __ b. C:\WAS6\AppServer\profiles\AppSvr01\bin> startServer server1 __ c. C:\WAS6\AppServer\profiles\AppSvr01\bin> serverStatus server1 4. Open the administration console. __ a. http://localhost:9060/admin __ b. Enter a User ID, then select the "Log in" button. 5. Verify that the UDDI registry application was started. __ a. Select "Applications", then "Enterprise Applications". __ b. UDDIRegistry.was60Node01.server1 should be Started 6. Verify that the UDDI node is active. __ a. Select UDDI - UDDI Nodes __ b. uddi:was60node01cell:was60node01:server1:default should be Activated 7. Examine the UDDI node settings by clicking on the URL for the UDDI Node ID. 8. Open the UDDI administration interface __ a. http://localhost:9080/uddigui/ 9. Explore registered services, businesses, and technical models __ a. Select the "Find" tab. __ b. Select Service with "Starting with:" % __ c. Select Business with "Starting with:" % __ d. Select Technical Model with "Starting with:" %

You have deployed a UDDI registry and examined some sample contents.

Populate the Registry Using UDDI Registry User Interface

1. Bring up the UDDI Registry user interface. __ a. http://localhost:9080/uddigui/ 2. Publish a business entry. __ a. Select the "Publish" tab. __ b. Select "Add a business". __ c. Enter the Name: Modern Cars, then select the "Add Name" URL. __ d. Select the "Show category tree" URL. __ e. Under "Taxonomies", expand "NAICS 2002", then "Retail Trade [44]", then "Motor Vehicle and Parts Dealers [441]", then "Automobile Dealers [4411]", then "Used Car Dealers [44112]", then select "Used Car Dealers [441120]". __ f. Notice "Categorizations" is populated. Select the "Publish Business" button. 3. View the business entry __ a. Select the "Find" URL at the top of the browser screen. __ b. Select the "Business" radio button, enter "M%" into the "Starting with" text field, then select the "Find" button. 4. You should see the business entry. 5. Add a service to the business entry. __ a. Select the "Publish" tab, then the "Show owned entities" URL. __ b. Select the "Add service" URL. __ c. Enter "Credit Check" into the "Name" text entry field, then select the "Add Name" URL. __ d. Select the "Add a Service Binding" URL. __ e. Enter the values for the "Access Point" and "Use Type" text entry fields, then select the "Add Access Point" URL. The Access Point should usually be "http://localhost:9080/JavaBean/services/CheckCreditBean", but the port might vary for your installation. The Use Type should be "http". __ f. Select the "Add Binding" button. __ g. Select the "Add Service" button to add the service to the business entry. __ h. You will see the resulting service entry.

You have added a business entry with a service into the UDDI registry.


Amunt! Top Amunt!
Libros
RedBook SG24-6583 : using Web Services for Business Integration

URL, T42

Service Pack IA81 : WebSphere Business Integration Message Broker and Web Services

This SupportPac examines the role that WebSphere Business Integration Message Broker can play in a Web Services environment.

URL

MB publib + "Developing Applications" on-line.

Web services scenarios

MB Message Flows :

MB v 6.0 Message Flows, page [53-55/1020].

Broker implements new Web service interface
In this Web service scenario, the broker provides a Web service interface to an existing non-web-service application.

  MB

Design steps

  1. Create a message set for the business messages, possibly by importing an existing interface definition such as a C header file or COBOL copybook.
  2. Generate a WSDL definition from the message set.
  3. Use a SOAP toolkit such as Rational Application Developer to create a suitable Web services client based on the WSDL.
  4. Develop a message flow to implement the Web service.

Example 1 - an existing CICS application has a COBOL copybook interface.
Example 2 - the message flow is invoked as a Web service
Example 3 - the message flow provides access to a WebSphere MQ application

  MB

  MB

URL

 

Amunt! Top Amunt!
MQ and Web Services

TMM44

HTTP connectivity to MQ

Alternative implementation as MA94.

Key features of the MQ bridge for HTTP:

HTTPconnectivity2MQ

The HTTP/WMQ API is largely based on REST. The API is modelled after REST ("Representational State Transfer") principles. REST offers a different integration style to WS-* standards based web services. Qualities of service are sacrificed for simplicity and scalability to keep barriers-to-entry low. It is a stateless / connectionless API with one HTTP verb corresponding to one WMQ operation. No client libraries are provided apps code directly to HTTP verbs using whatever APIs are in the environment. REST was described by Roy Fielding in http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm.

TMM07


Amunt! Top Amunt!
WebServices high availability

A web service request comes out as a URL, related to a specific IP. If we want to provide access to two (or more) diferent servers, we can use a hardwar as F5

Homepage, wiki,


Amunt! Top Amunt!
Links

Ep ! Valid HTML 4.01!   Valid CSS! Escriu-me !
Updated 20140408 (a)  
Uf !