http://www.packtpub.com/jboss-esb-beginners-guide/book
This is the blog site for the JBossESB team. Although we will predominately concentrate on the JBossESB project, expect entries on ESB and SOA concepts in general.
http://www.packtpub.com/jboss-esb-beginners-guide/book
We've been making some good progress with the JBoss Tools Smooks Editor. The following are two rough Screencasts (audio is poorly edited... apologies) illustrating two use cases that extend from each other.
In this Screencast, we bind EDI Purchase Order data (but can also be XML, JSON etc) into an "Order" object model (Java). This Screencast was created a few weeks ago, using the v3.1.0.CR1 release of JBoss Tools.
In this Screencast, we extend the example shown in the above Screencast, applying a template to the "Order" object model to produce an XML Purchase Order. The XML Purchase Order is defined in an XML Schema (XSD), but you'll see how the editor makes it very easy to work with the XSD. This Screencast was created recently, using one of the Nightly Builds of JBoss Tools.
We are currently working towards the v3.1.0.CR2 release of JBoss Tools, which is due to be released in Feb (not sure of exact date). There are still a number of issues with the editor. We are working on these and will be resolving many of them for the 3.1.0.CR2 release.
We have purposely restricted the 3.1.0 version of the editor:
So, the editor will not support:
Please take the editor for a spin and let us know what you think. It can be downloaded (standalone, or as part of JBoss Tools) from the JBoss Tools Downloads Page. Please log any issues you find with the editor (against the "smooks" component), if not already logged.
1: <service category="Vehicles" name="Cars" description="" invmScope="GLOBAL">
2: <listeners>
3: <http-gateway name="Http" />
4: </listeners>
5: <actions mep="RequestResponse">
6: <!-- Service Actions.... -->
7: </actions>
8: </service>
Like a lot of things with JBossESB, you can do a lot with a little. Let's examine this example line-by-line:1: http://<host>:<port>/<.esbname>/http/Vehicles/Cars
The host and port number come from the ESB server. The "<.esbname>" token is the actual name of the deployed .esb archive, minus the .esb extension. Note that while this string is an HTTP URL, it's also an endpoint. The prefix of "http" is actually a namespace that is used for all the http-gateway endpoints.1: <service category="Vehicles" name="Cars" description="" invmScope="GLOBAL">
2: <listeners>
3: <http-gateway name="Http" urlPattern="esb-cars/*" />
4: </listeners>
5: <actions mep="RequestResponse">
6: <!-- Service Aactions.... -->
7: </actions>
8: </service>
Then, the service's exposed HTTP endpoint would capture incoming HTTP requests at this address:1: http://<host>:<port>/<.esbname>/http/esb-cars/*
1: Map params = (Map) message.getProperties().getProperty(“RequestParameterMap”);
The RequestInfoMap is another java.util.Map that contains request information such as authType, characterEncoding, HTTP Method, remoteHost, contentLength, etc.. You can access the parameters in your service's actions by:1: Map params = (Map) message.getProperties().getProperty(“RequestInfoMap”);
Let's switch gears now and look at a more extensive example.1: <globals>
2: <!-- Security setting for all http-providers and all EBWSs in this jboss-esb.xml file.-->
3: <war-security method="BASIC" domain="JBossWS" />
4: </globals>
This "global" section is new with the http-gateway in JBossESB 4.7. Like the comment says, this defines the global security setting for all the http and EBWS providers in this application. The other supported settings for the war-security method are: DIGEST [4] and CLIENT-CERT.1: <http-provider name="http">
2: <http-bus busid="secureFriends">
3: <!-- Only users in the "friend" role are allowed
4: access via the "GET" method. Unspecified
5: methods are not protected (i.e. are allowed)... -->
6: <allowed-roles>
7: <role name="friend" />
8: </allowed-roles>
9: <protected-methods>
10: <method name="GET" />
11: <method name="POST" />
12: </protected-methods>
13: </http-bus>
14: <!-- Global exception mappings file... -->
15: <exception mappingsFile="/http-exception-mappings.properties" />
16: </http-provider>
In this file fragment we see:1: <service category="Sales" name="List" description="" invmScope="GLOBAL">
2: <listeners>
3: <!-- Receives: http://<host>:<port>/Quickstart_http_gateway/http/sales/* but will be forced to
4: authenticate because the "sales" bus has basic auth configured (above)... -->
5: <http-gateway name="sales" busidref="secureFriends" urlPattern="sales/*" />
6: </listeners>
7: <actions mep="RequestResponse">
8: <action name="print" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyAction"/>
9: </actions>
10: </service>
Here's where it all ties together:1: lynx -dump -source -auth=kermit:thefrog http://localhost:8080/Quickstart_http_gateway/http/sales/a/b/c
2: Service: Sales:List
3:
4: ------------Http Request Info (XStream Encoded)-------------------
5: <org.jboss.soa.esb.http.HttpRequest>
6: <authType>BASIC</authType>
7: <contextPath>/Quickstart_http_gateway</contextPath>
8: <localAddr>127.0.0.1</localAddr>
9: <localName>localhost.localdomain</localName>
10: <method>GET</method>
11: <pathInfo>/a/b/c</pathInfo>
12: <protocol>HTTP/1.0</protocol>
13: <remoteAddr>127.0.0.1</remoteAddr>
14: <remoteHost>127.0.0.1</remoteHost>
15: <remoteUser>kermit</remoteUser>
16: <contentLength>-1</contentLength>
17: <requestURI>/Quickstart_http_gateway/http/sales/a/b/c</requestURI>
18: <scheme>http</scheme>
19: <serverName>localhost</serverName>
20: <requestPath>/http/sales</requestPath>
21: <pathInfoTokens>
22: <string>a</string>
23: <string>b</string>
24: <string>c</string>
25: </pathInfoTokens>
26: <queryParams/>
27: <headers>
28: <org.jboss.soa.esb.http.HttpHeader>
29: <name>host</name>
30: <value>localhost:8080</value>
31: </org.jboss.soa.esb.http.HttpHeader>
32: <org.jboss.soa.esb.http.HttpHeader>
33: <name>accept</name>
34: <value>text/html, text/plain, audio/mod, image/*, application/msword, application/pdf, application/postscript, application/x-java-jnlp-file, text/sgml, video/mpeg, */*;q=0.01</value>
35: </org.jboss.soa.esb.http.HttpHeader>
36: <org.jboss.soa.esb.http.HttpHeader>
37: <name>accept-language</name>
38: <value>en</value>
39: </org.jboss.soa.esb.http.HttpHeader>
40: <org.jboss.soa.esb.http.HttpHeader>
41: <name>user-agent</name>
42: <value>Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8e-fips-rhel5</value>
43: </org.jboss.soa.esb.http.HttpHeader>
44: <org.jboss.soa.esb.http.HttpHeader>
45: <name>authorization</name>
46: <value>Basic a2VybWl0OnRoZWZyb2c=</value>
47: </org.jboss.soa.esb.http.HttpHeader>
48: </headers>
1: <service category="Index" name="List" description="" invmScope="GLOBAL">
2: <listeners>
3: <!-- Receives: http://<host>:<port>/Quickstart_http_gateway/http/index/*
4: Uses the default http bus configuration... -->
5: <http-gateway name="Index" urlPattern="index/*" />
6: </listeners>
7: <actions mep="RequestResponse">
8: <action name="print" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyAction"/>
9: </actions>
10: </service>
1: lynx -dump -source http://localhost:8080/Quickstart_http_gateway/http/index/XXXX/yyy?a=1,b=2
2: Service: Index:List
3:
4: ------------Http Request Info (XStream Encoded)-------------------
5: <org.jboss.soa.esb.http.HttpRequest>
6: <contextPath>/Quickstart_http_gateway</contextPath>
7: <localAddr>127.0.0.1</localAddr>
8: <localName>localhost.localdomain</localName>
9: <method>GET</method>
10: <pathInfo>/XXXX/yyy</pathInfo>
11: <protocol>HTTP/1.0</protocol>
12: <queryString>a=1,b=2</queryString>
13: <remoteAddr>127.0.0.1</remoteAddr>
14: <remoteHost>127.0.0.1</remoteHost>
15: <contentLength>-1</contentLength>
16: <requestURI>/Quickstart_http_gateway/http/index/XXXX/yyy</requestURI>
17: <scheme>http</scheme>
18: <serverName>localhost</serverName>
19: <requestPath>/http/index</requestPath>
20: <pathInfoTokens>
21: <string>XXXX</string>
22: <string>yyy</string>
23: </pathInfoTokens>
24: <queryParams>
25: <entry>
26: <string>a</string>
27: <string-array>
28: <string>1,b=2</string>
29: </string-array>
30: </entry>
31: </queryParams>
32: <headers>
33: <org.jboss.soa.esb.http.HttpHeader>
34: <name>host</name>
35: <value>localhost:8080</value>
36: </org.jboss.soa.esb.http.HttpHeader>
37: <org.jboss.soa.esb.http.HttpHeader>
38: <name>accept</name>
39: <value>text/html, text/plain, audio/mod, image/*, application/msword, application/pdf, application/postscript, application/x-java-jnlp-file, text/sgml, video/mpeg, */*;q=0.01</value>
40: </org.jboss.soa.esb.http.HttpHeader>
41: <org.jboss.soa.esb.http.HttpHeader>
42: <name>accept-language</name>
43: <value>en</value>
44: </org.jboss.soa.esb.http.HttpHeader>
45: <org.jboss.soa.esb.http.HttpHeader>
46: <name>user-agent</name>
47: <value>Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8e-fips-rhel5</value>
48: </org.jboss.soa.esb.http.HttpHeader>
49: </headers>
Take special note of these lines:1: <queryParams>
2: <entry>
3: <string>a</string>
4: <string-array>
5: <string>1,b=2</string>
6: </string-array>
7: </entry>
8: </queryParams>
Let's change the URL a bit and make sure that the query parameters can really be accessed by the service and its actions:1: lynx -dump -source http://localhost:8080/Quickstart_http_gateway/http/index/XXXX/yyy?param1=hello,param2=world
2:
3: <queryParams>
4: <entry>
5: <string>param1</string>
6: <string-array>
7: <string>hello,param2=world</string>
8: </string-array>
9: </entry>
10: </queryParams>
Yup! It's them!1: <!-- Global exception mappings file... -->
2: <<exception mappingsFile="/http-exception-mappings.properties" />
As its name indicates, this feature enables you to define a status code that will be returned for all requests that are received by a service. Let's take a look at the http-exception-mappings.properties file:1: org.jboss.soa.esb.services.security.SecurityServiceException=401
2: org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException=502
What this file indicates is that all requests that raise an exception of type org.jboss.soa.esb.services.security.SecurityServiceException will result in an HTTP return status code of 401 being returned to the client that sent in the request, and all requests that raise an exception of type org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException will result in an HTTP return sttaus code of 502 being returned. To illustrate how this, we'll invoke this service:1: <service category="Exceptions" name="Exception1" description="" invmScope="GLOBAL">
2: <listeners>
3: <http-gateway name="Exception2" />
4: </listeners>
5: <actions mep="RequestResponse">
6: <!-- Uses the globally defined exception mappings defined on the <http-provider>... -->
7: <action name="print" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyExceptionAction"/>
8: </actions>
9: </service>
The MyExceptionAction class is minimal - just enough code to throw an exception:1: public class MyExceptionAction extends AbstractActionPipelineProcessor {
2:
3: public MyExceptionAction(ConfigTree config) {
4: }
5:
6: public Message process(Message message) throws ActionProcessingException {
7: throw new MyActionException("MyActionException!!!!");
8: }
9:
To access this service, you point your browser at this URL: http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception11: lynx -dump -source http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception1 -error_file=error.txt
2: org.jboss.soa.esb.couriers.FaultMessageException: org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException: MyActionException!!!!
3: at org.jboss.soa.esb.listeners.message.errors.Factory.createExceptionFromFault(Factory.java:50)
4: at org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl.pickup(TwoWayCourierImpl.java:207)
5: at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.attemptDelivery(ServiceInvoker.java:675)
6: at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.access$200(ServiceInvoker.java:569)
7: at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:359)
8: at org.jboss.soa.esb.client.ServiceInvoker.deliverSync(ServiceInvoker.java:219)
9: at org.jboss.soa.esb.listeners.gateway.http.HttpGatewayServlet.service(HttpGatewayServlet.java:187)
10: at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
11: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
12: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
13: at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
15: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
16: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
17: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
18: at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
19: at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
20: at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
21: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
22: at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
23: at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
24: at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
25: at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
26: at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
27: at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
28: at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
29: at java.lang.Thread.run(Thread.java:636)
30: Caused by: org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException: MyActionException!!!!
31: at org.jboss.soa.esb.samples.quickstart.httpgateway.MyExceptionAction.process(MyExceptionAction.java:34)
32: at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:634)
33: at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:586)
34: at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:420)
35: at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540)
36: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
37: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
38: ... 1 more
And - here's the return code that we wanted:1: cat error.txt
2: URL=http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception1 (GET)
3: STATUS=HTTP/1.1 502 Bad Gateway
1: <service category="Exceptions" name="Exception2" description="" invmScope="GLOBAL">
2: <listeners>
3: <http-gateway name="Exception1">
4: <!-- Override the exception mappings defined on the <http-provider>... -->
5: <exception>
6: <mapping class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException" status="503" />
7: </exception>
8: </http-gateway>
9: </listeners>
10: <actions mep="RequestResponse">
11: <!-- Uses the override exception mappings defined on the <http-gateway>... -->
12: <action name="print" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyExceptionAction"/>
13: </actions>
14: </service>
Line 6 is the one that we're interested in. Here's where we map the class that throws the exception to the code that is returned. And, here's what happens:1: lynx -dump -source http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception2 -error_file=error.txt
2: org.jboss.soa.esb.couriers.FaultMessageException: org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException: MyActionException!!!!
3: at org.jboss.soa.esb.listeners.message.errors.Factory.createExceptionFromFault(Factory.java:50)
4: at org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl.pickup(TwoWayCourierImpl.java:207)
5: at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.attemptDelivery(ServiceInvoker.java:675)
6: at org.jboss.soa.esb.client.ServiceInvoker$EPRInvoker.access$200(ServiceInvoker.java:569)
7: at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:359)
8: at org.jboss.soa.esb.client.ServiceInvoker.deliverSync(ServiceInvoker.java:219)
9: at org.jboss.soa.esb.listeners.gateway.http.HttpGatewayServlet.service(HttpGatewayServlet.java:187)
10: at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
11: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
12: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
13: at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
14: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
15: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
16: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
17: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
18: at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
19: at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
20: at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
21: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
22: at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
23: at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
24: at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
25: at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
26: at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
27: at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
28: at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
29: at java.lang.Thread.run(Thread.java:636)
30: Caused by: org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException: MyActionException!!!!
31: at org.jboss.soa.esb.samples.quickstart.httpgateway.MyExceptionAction.process(MyExceptionAction.java:34)
32: at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:634)
33: at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:586)
34: at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:420)
35: at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540)
36: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
37: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
38: ... 1 more
39:
40: cat error.txt
41: URL=http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception2 (GET)
42: STATUS=HTTP/1.1 503 Service Unavailable
1: <service category="Async" name="List" description="" invmScope="GLOBAL">
2: <listeners>
3: <!-- Receives: http://<host>:<port>/Quickstart_http_gateway/http/Async/List
4: Uses the default http bus configuration... -->
5: <http-gateway name="Async">
6: <asyncResponse statusCode="202">
7: <payload classpathResource="/readme.txt" contentType="text/plain" characterEncoding="UTF-8" />
8: </asyncResponse>
9: </http-gateway>
10: </listeners>
11: <actions mep="RequestResponse">
12: <action name="print" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyAction"/>
13: </actions>
14: </service>
1: lynx -dump -source http://localhost:8080/Quickstart_http_gateway/http/Async/List -error_file=error.txt
2: Overview:
3: =========
4: The purpose of the http_gateway quickstart sample is to demonstarte how to
5: configue a http gateway to pass the http request into ESB service.
6:
7:
8: Running this quickstart:
9: ========================
10: Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
11: and a more detailed descripton of the different ways to run the quickstarts.
12:
13: To Run '.esb' archive mode:
14: ===========================
15: 1. In a command terminal window in this folder ("Window1"), type 'ant deploy'.
16: 2. Open the web brower and send http requests to the following addresses. Be sure to
17: check the Server console after executing each request:
18: a) http://localhost:8080/Quickstart_http_gateway/http/sales/a/b/c - Will be routed to the Sales:List
19: service. Will return some details about the request. This Service's <http-gateway> references a
20: "secureFriends" bus, which contains login configurations. The login username is "kermit" and the
21: password is "thefrog". It usee the "java:/jaas/JBossWS" security domain, which is already installed
22: in your JBoss ESB/App Server.
23: b) http://localhost:8080/Quickstart_http_gateway/http/index/XXXX/yyy?a=1,b=2 - Will be routed to the Index:List
24: service. Will return some details about the request. This Service's <http-listener> does not refer
25: to any bus and so simply uses the "default" http bus.
26: c) http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception1 - Will be routed to the
27: Exceptions:Exception1 service. This service throws a "MyActionException", resulting in a
28: 502 (Bad Gateway) status being returned in accordance with the Exception to HTTP status code
29: mappings defined globally on the <http-provider>.
30: d) http://localhost:8080/Quickstart_http_gateway/http/Exceptions/Exception2 - Will be routed to the
31: Exceptions:Exception2 service. This service also throws a "MyActionException", but the <http-gateway>
32: on this service overrides the globally defined Exception to HTTP status code mappings defined globally
33: on the <http-provider> to return a 503 (Service Unavailable) status for the "MyActionException" exception.
34: e) http://localhost:8080/Quickstart_http_gateway/http/Async/List - Will be routed to the
35: Async:List service, which responds asynchronously with a 202 (Accepted) response code and a static
36: payload of this readme.txt.
37: f) http://localhost:8080/Quickstart_http_gateway/http/soap/ - Will be routed to the
38: Soap:List service, which requires message level seurity. An 401 error will occur. Now
39: switch to the command line and run "ant soap". This POSTs a SOAP message, with login credentials
40: to the gateway. The service should respond successfully this time!!
41: 3. In this folder ("Window1"), type 'ant undeploy'.
42:
43: cat error.txt
44: URL=http://localhost:8080/Quickstart_http_gateway/http/Async/List (GET)
45: STATUS=HTTP/1.1 202 Accepted
1: <service category="Soap" name="List" description="" invmScope="GLOBAL">
2: <listeners>
3: <!-- Receives: http://<host>:<port>/Quickstart_http_gateway/http/soap/*
4: Execute "ant soap" on command line.... -->
5: <http-gateway name="soap" busidref="secureFriends" urlPattern="soap/*">
6: <exception>
7: <mapping class="org.jboss.soa.esb.services.security.SecurityServiceException" status="401" />
8: </exception>
9: </http-gateway>
10: </listeners>
11: <actions mep="RequestResponse">
12: <action name="print" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyAction"/>
13: </actions>
14: </service>
1: lynx -dump -source http://localhost:8080/Quickstart_http_gateway/http/soap -error_file=error.txt
2: HTTP: Access authorization required.
3: Use the -auth=id:pw parameter.
4:
5: Looking up localhost:8080
6: Making HTTP connection to localhost:8080
7: Sending HTTP request.
8: HTTP request sent; waiting for response.
9: Alert!: Access without authorization denied -- retrying
10:
11: lynx: Can't access startfile http://localhost:8080/Quickstart_http_gateway/http/soap
12:
13: cat error.txt
14: URL=http://localhost:8080/Quickstart_http_gateway/http/soap (GET)
15: STATUS=HTTP/1.1 401 Unauthorized
Now, we could just provide login credentials manually through the browser UI, but we want our client code to be able to do this programatically. The answer to avoiding this exception, is ot have request that we send has to include login credentials. The quickstart's build.xml file provides an ant target to do this for you by invoking the JBossESB HttpRouter action (org.jboss.soa.esb.actions.routing.http.HttpRouter). This action is one of the JBossESB's large set of "out-of-the-box" actions.1: <target name="soap" depends="compile" description="sends a SOAP HTTP request to the http gateway">
2: <echo>Http Client</echo>
3: <java fork="yes" classname="org.jboss.soa.esb.actions.routing.http.HttpRouter" failonerror="true">
4: <arg value="endpointUrl=http://localhost:8080/Quickstart_http_gateway/http/soap/"/>
5: <!-- The EBWS is secured with container level security -->
6: <arg value="configurators=HttpProtocol,AuthBASIC"/>
7: <arg value="method=POST"/>
8: <arg value="auth-username=kermit"/>
9: <arg value="auth-password=thefrog"/>
10: <arg value="authscope-host=localhost"/>
11: <arg value="authscope-port=8080"/>
12: <!-- The actual payload to POST -->
13: <arg value="payload=soap-login.xml"/>
14: <classpath refid="exec-classpath"/>
15: </java>
16: </target>
The actual message payload that is sent is defined in the soap-login.xml file is:1: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
2: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3: xmlns:xsd="http://www.w3.org/2001/XMLSchema">
4:
5: <soap:Header>
6: </soap:Header>
7:
8: <soap:Body>
9: </soap:Body>
10:
11: </soap:Envelope>
And, the successful results look like this:1: soap:
2: [echo] Http Client
3: [java] Request payload:
4: [java] <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
5: [java] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6: [java] xmlns:xsd="http://www.w3.org/2001/XMLSchema">
7: [java]
8: [java] <soap:Header>
9: [java] </soap:Header>
10: [java]
11: [java] <soap:Body>
12: [java] </soap:Body>
13: [java]
14: [java] </soap:Envelope>
15: [java]
16: [java] --------------------------
17: [java]
18: [java]
19: [java] Response Status Code: 200
20: [java] Response payload:
21: [java] Service: Soap:List
22: [java]
23: [java] ------------Http Request Info (XStream Encoded)-------------------
24: [java] <org.jboss.soa.esb.http.HttpRequest>
25: [java] <authType>BASIC</authType>
26: [java] <characterEncoding>UTF-8</characterEncoding>
27: [java] <contentType>text/xml;charset=UTF-8</contentType>
28: [java] <contextPath>/Quickstart_http_gateway</contextPath>
29: [java] <localAddr>127.0.0.1</localAddr>
30: [java] <localName>localhost.localdomain</localName>
31: [java] <method>POST</method>
32: [java] <pathInfo>/</pathInfo>
33: [java] <protocol>HTTP/1.1</protocol>
34: [java] <remoteAddr>127.0.0.1</remoteAddr>
35: [java] <remoteHost>127.0.0.1</remoteHost>
36: [java] <remoteUser>kermit</remoteUser>
37: [java] <contentLength>268</contentLength>
38: [java] <requestURI>/Quickstart_http_gateway/http/soap/</requestURI>
39: [java] <scheme>http</scheme>
40: [java] <serverName>localhost</serverName>
41: [java] <requestPath>/http/soap</requestPath>
42: [java] <pathInfoTokens/>
43: [java] <queryParams/>
44: [java] <headers>
45: [java] <org.jboss.soa.esb.http.HttpHeader>
46: [java] <name>content-type</name>
47: [java] <value>text/xml;charset=UTF-8</value>
48: [java] </org.jboss.soa.esb.http.HttpHeader>
49: [java] <org.jboss.soa.esb.http.HttpHeader>
50: [java] <name>user-agent</name>
51: [java] <value>Jakarta Commons-HttpClient/3.0.1</value>
52: [java] </org.jboss.soa.esb.http.HttpHeader>
53: [java] <org.jboss.soa.esb.http.HttpHeader>
54: [java] <name>content-length</name>
55: [java] <value>268</value>
56: [java] </org.jboss.soa.esb.http.HttpHeader>
57: [java] <org.jboss.soa.esb.http.HttpHeader>
58: [java] <name>authorization</name>
59: [java] <value>Basic a2VybWl0OnRoZWZyb2c=</value>
60: [java] </org.jboss.soa.esb.http.HttpHeader>
61: [java] <org.jboss.soa.esb.http.HttpHeader>
62: [java] <name>host</name>
63: [java] <value>localhost:8080</value>
64: [java] </org.jboss.soa.esb.http.HttpHeader>
65: [java] </headers>
66: [java] </org.jboss.soa.esb.http.HttpRequest>
67: [java] --------------------------
68: [java]