Error while attempting to call Web Service using SOAPClient
dansalt Oct 23, 2007 4:48 AMHi,
I'm using JBoss ESB4.2GA running within JBoss AS 4.2.1GA. I've got the Quickstarts up and running and all seems to be OK. I'm now trying to prototype some code and am running into problems.
I've got a number of Web Services deployed and want to use the ESB as a "proxy" to them. So I have an ESB project that receives the WS SOAP message, routes to the SOAPClient which calls the "real" Web Service.
I started with no code and the following config:
<?xml version="1.0" encoding="UTF-8"?> <jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5" > <providers> <jms-provider name="JBossMQ" connection-factory="ConnectionFactory" jndi-context-factory="org.jnp.interfaces.NamingContextFactory" jndi-URL="localhost"> <jms-bus busid="lightESBChannel"> <jms-message-filter dest-type="QUEUE" dest-name="queue/light_services_gateway_esb"/> </jms-bus> <jms-bus busid="lightESBReplyChannel"> <jms-message-filter dest-type="QUEUE" dest-name="queue/light_services_gateway_esb_reply"/> </jms-bus> </jms-provider> <jbr-provider name="JBR-Http" protocol="http" host="localhost"> <jbr-bus busid="Http-1" port="9876" /> </jbr-provider> </providers> <services> <service category="LightSwitchServices" name="serviceGW" description="Light Switch ESB Service GW"> <listeners> <jbr-listener name="HttpListener" busidref="Http-1" is-gateway="true" maxThreads="1" /> <jms-listener name="JMS-ESBListener" busidref="lightESBChannel" maxThreads="1" /> </listeners> <actions> <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln"> <property name="message" value="[service gateway] BEFORE routing message to WS"/> </action> <action name="soapui-client-action" class="org.jboss.soa.esb.actions.soap.SOAPClient"> <property name="wsdl" value="http://localhost:8080/LightServices/LightSwitchBean?wsdl" /> <property name="SOAPAction" value="switchOnLight"/> </action> </actions> </service> </services> </jbossesb>
When I run this, I got the following error:
09:28:56,757 INFO [ServiceInvoker] Unresponsive EPR: EPR: PortReference < <wsa:Address http://localhost:9876/> > 09:28:56,898 INFO [STDOUT] [service gateway] BEFORE routing message to WS: 09:28:56,898 INFO [STDOUT] [<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns1:switchOnLight xmlns:ns1="http://ejb.examples.soa.systems.energy.ge/"/></env:Body></env:Envelope>]. 09:28:56,898 WARN [ActionProcessingPipeline] Unexpected exception caught while processing the action pipeline java.lang.ClassCastException: java.lang.String at org.jboss.soa.esb.actions.soap.SOAPClient.process(SOAPClient.java:304) at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:265) at org.jboss.soa.esb.listeners.message.MessageAwareListener$1.run(MessageAwareListener.java:297) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595)
Looking into this, it appears that the method in question (SOAPClient.java:304) was having problems with the fact that my Web Service does not take or return any parameters. In the event of a empty map, it tries to take the Message Body and cast it to a map. In the case above, it was a String, thus the failure.
Now I appreciate that the documentation says that I must set an empty map, but surely it would be neater to handle this case without custom code?
Anyways, I create a basic pre/post class which simply sets an empty map in the message. I added the following:
<action name="pre-request-mapper" class="ge.energy.systems.soa.examples.esb.actions.EmptyParameterRequestMapper" />
This now gets much further, calls my Web Service, but then fails on the return.
09:32:48,726 INFO [STDOUT] [service gateway] BEFORE routing message to WS:
09:32:48,726 INFO [STDOUT] [<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns1:switchOnLight xmlns:ns1="http://ejb.examples.soa.systems.energy.ge/"/></env:Body></env:Envelope>].
09:32:48,726 WARN [SOAPClient] Params Map found in message, but the map is empty.
09:32:50,195 INFO [STDOUT] 09:32:50,195 WARN [SoapUI] Failed to load settings [soapui-settings.xml (The system cannot find the file specified)], creating new
09:32:52,617 INFO [STDOUT] Progress: 1 - Caching definition from url [http://localhost:8080/LightServices/LightSwitchBean?wsdl]
09:32:52,742 INFO [STDOUT] 09:32:52,742 INFO [SchemaUtils] Added default schema from file:/D:/DevEnvironments/JBossESB/jboss-4.2.1.GA/server/default/tmp/deploy/tmp19970soapui-1.7.1.jar!/xop.xsd with targetNamespace http://www.w3.org/2004/08/xop/include
09:32:52,945 INFO [STDOUT] 09:32:52,945 INFO [SchemaUtils] Added default schema from file:/D:/DevEnvironments/JBossESB/jboss-4.2.1.GA/server/default/tmp/deploy/tmp19970soapui-1.7.1.jar!/XMLSchema.xsd with targetNamespace http://www.w3.org/2001/XMLSchema
09:32:52,960 INFO [STDOUT] 09:32:52,960 INFO [SchemaUtils] Added default schema from file:/D:/DevEnvironments/JBossESB/jboss-4.2.1.GA/server/default/tmp/deploy/tmp19970soapui-1.7.1.jar!/xml.xsd with targetNamespace http://www.w3.org/XML/1998/namespace
09:32:52,992 INFO [STDOUT] 09:32:52,992 INFO [SchemaUtils] Added default schema from file:/D:/DevEnvironments/JBossESB/jboss-4.2.1.GA/server/default/tmp/deploy/tmp19970soapui-1.7.1.jar!/swaref.xsd with targetNamespace http://ws-i.org/profiles/basic/1.1/xsd
09:32:52,992 INFO [STDOUT] 09:32:52,992 INFO [SchemaUtils] Added default schema from file:/D:/DevEnvironments/JBossESB/jboss-4.2.1.GA/server/default/tmp/deploy/tmp19970soapui-1.7.1.jar!/xmime200505.xsd with targetNamespace http://www.w3.org/2005/05/xmlmime
09:32:52,992 INFO [STDOUT] 09:32:52,992 INFO [SchemaUtils] Added default schema from file:/D:/DevEnvironments/JBossESB/jboss-4.2.1.GA/server/default/tmp/deploy/tmp19970soapui-1.7.1.jar!/xmime200411.xsd with targetNamespace http://www.w3.org/2004/11/xmlmime
09:32:53,273 INFO [STDOUT] 09:32:53,273 WARN [HttpMethodBase] Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
09:32:53,351 INFO [STDOUT] Progress: 1 - Loading definition from cache
09:32:53,460 INFO [STDOUT] Retrieving document at 'http://localhost:8080/LightServices/LightSwitchBean?wsdl'.
09:32:53,960 INFO [STDOUT] 09:32:53,960 INFO [SchemaUtils] Loading schema types from [http://localhost:8080/LightServices/LightSwitchBean?wsdl]
09:32:53,960 INFO [STDOUT] 09:32:53,960 INFO [SchemaUtils] Getting schema http://localhost:8080/LightServices/LightSwitchBean?wsdl
09:32:53,976 INFO [STDOUT] 09:32:53,976 INFO [SchemaUtils] schema for [http://ejb.examples.soa.systems.energy.ge/] contained [{}] namespaces
09:32:54,601 INFO [STDOUT] 09:32:54,601 INFO [WsdlImporter] Finding importer for {http://ejb.examples.soa.systems.energy.ge/}LightSwitchBinding
09:32:54,601 INFO [STDOUT] 09:32:54,601 INFO [WsdlImporter] Importing binding {http://ejb.examples.soa.systems.energy.ge/}LightSwitchBinding
09:32:54,742 INFO [STDOUT] 09:32:54,742 INFO [Soap11HttpBindingImporter] importing endpoint http://127.0.0.1:8080/LightServices/LightSwitchBean
09:32:54,851 INFO [STDOUT] 09:32:54,851 INFO [Soap11HttpBindingImporter] importing operation isLightOn
09:32:54,945 INFO [STDOUT] 09:32:54,945 INFO [Soap11HttpBindingImporter] importing operation switchOffLight
09:32:54,945 INFO [STDOUT] 09:32:54,945 INFO [Soap11HttpBindingImporter] importing operation switchOnLight
09:32:55,304 WARN [HttpMethodBase] Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
09:32:55,335 ERROR [SOAPMessageUnMarshaller] Cannot unmarshall SOAPMessage
javax.xml.soap.SOAPException: Unsupported content type: text/html
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:240)
at org.jboss.ws.core.soap.SOAPMessageUnMarshaller.read(SOAPMessageUnMarshaller.java:75)
at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:472)
at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:304)
at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:135)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
at org.jboss.remoting.Client.invoke(Client.java:1550)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.ws.core.client.RemotingConnectionImpl.invoke(RemotingConnectionImpl.java:171)
at org.jboss.ws.core.client.SOAPRemotingConnection.invoke(SOAPRemotingConnection.java:77)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:322)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:230)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:164)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)
at $Proxy113.switchOnLight(Unknown Source)
at ge.energy.systems.soa.examples.web.LightTest.doGet(LightTest.java:195)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
I wasn't able to accurately debug what was going on - can anyone help me? The "real" WebService works fine outside of this example. It's prototype is very simply:
void switchOnLight()
Many Thanks,
Dan