[JBossWS] - Newbee Q: Returning hashmaps
by soch
I am trying to take the simple echo example (http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS_JAX-WS_Tools) to the next level and running into problem.
I want to return a hashmap instead of the string.
Instead of the client printing the hasmap contents it prints the address of the the hashmap.
I am using the new tools: wsconsume, wsprovide & wsrunclient.
Here's the code:
GetPM.java:
=========
package getpm;
|
| import java.util.HashMap;
|
| @javax.jws.WebService
| public class GetPM
| {
|
| HashMap map = new HashMap();
|
| public HashMap getPM()
| {
| map.put("key1", "value1");
| map.put("key2", "value2");
| map.put("key3", "value3");
| System.out.println("From Server:" + map.toString());
| return map;
| }
| }
I am using the same web.xml as in the echo example -- is this were I am going wrong?
web.xml
=======
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
| version="2.4">
|
| <servlet>
| <servlet-name>GetPM</servlet-name>
| <servlet-class>getpm.GetPM</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>GetPM</servlet-name>
| <url-pattern>/GetPM</url-pattern>
| </servlet-mapping>
| </web-app>
I created the getpm.war file & deployed it on the jboss AS.
Using wsconsume created the client files using the online version of service wsdl file: wsconsume -k http://localhost:8080/getpm/GetPM?wsdl
The client then calls the service using the following
GetPMclient.java:
=============
import getpm.*;
|
| public class GetPMclient
| {
| public static void main(String args[])
| {
| GetPMService service = new GetPMService();
| GetPM pm = service.getGetPMPort();
| System.out.println("Server said: " + pm.getPM());
|
| //HashMap hm = (HashMap) pm.getPM();
| //System.out.println(hm.toString());
| }
| }
On the server stdout I get the hashmap printed correctly, but on the client side instead of the hashmap I get the reference of the hashmap as below:
getpm.HashMap@1a0b53e
instead of
{key1=value1, key2=value2, key3=value3}
C:\....\webservices\getpm\client\output>wsrunclient GetPMclient
log4j:WARN No appenders could be found for logger (org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder).
log4j:WARN Please initialize the log4j system properly.
Server said:
getpm.HashMap@1a0b53e
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147385#4147385
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147385
17 years, 11 months
[JBossWS] - Re: Cannot expose EJB 3 as WS
by peiguo
Hm... After I read your reply, I tried two things but both failed, not sure what we did differently (I am using 4.2.2.GA).
1) I removed the config.xml file, when I deploy I got this:
| 15:07:45,192 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
|
| --- Packages waiting for a deployer ---
| org.jboss.deployment.DeploymentInfo@9f91cc6f { url=file:/C:/jboss-4.2.2.GA/serve
| r/default/deploy/endpoint/Hello.class }
| deployer: null
| status: null
| state: INIT_WAITING_DEPLOYER
| watch: file:/C:/jboss-4.2.2.GA/server/default/deploy/endpoint/Hello.class
| altDD: null
| lastDeployed: 1209420465192
| lastModified: 1209420465192
| mbeans:
|
| --- Incompletely deployed packages ---
| org.jboss.deployment.DeploymentInfo@9f91cc6f { url=file:/C:/jboss-4.2.2.GA/serve
| r/default/deploy/endpoint/Hello.class }
| deployer: null
| status: null
| state: INIT_WAITING_DEPLOYER
| watch: file:/C:/jboss-4.2.2.GA/server/default/deploy/endpoint/Hello.class
| altDD: null
| lastDeployed: 1209420465192
| lastModified: 1209420465192
| mbeans:
|
2) the config.xml is still removed like option, but I added wsdlLocation in my code like this:
| @Stateless
| @WebService(endpointInterface="org.jboss.tutorial.webservice.bean.Calculator", wsdlLocation="http://localhost:8080/tutorial/CalculatorBean?wsdl")
|
And I got this:
| 15:10:27,020 ERROR [MainDeployer] Could not start deployment: file:/C:/jboss-4.2
| .2.GA/server/default/deploy/tutorial.jar
| org.jboss.ws.metadata.wsdl.WSDLException: Cannot parse wsdlLocation: http://loca
| lhost:8080/tutorial/CalculatorBean?wsdl
| at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDefini
| tionsFactory.java:183)
| at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsF
| actory.java:108)
| at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.pr
| ocessOrGenerateWSDL(JAXWSWebServiceMetaDataBuilder.java:373)
| at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.bu
| ildWebServiceMetaData(JAXWSWebServiceMetaDataBuilder.java:158)
| at org.jboss.ws.metadata.builder.jaxws.JAXWSServerMetaDataBuilder.setupP
| roviderOrWebService(JAXWSServerMetaDataBuilder.java:50)
| at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilderEJB3.buildMet
| aData(JAXWSMetaDataBuilderEJB3.java:78)
| at org.jboss.wsf.stack.jbws.UnifiedMetaDataDeploymentAspect.create(Unifi
| edMetaDataDeploymentAspect.java:71)
| at org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl.deploy
| (DeploymentAspectManagerImpl.java:115)
| at org.jboss.wsf.container.jboss42.ArchiveDeployerHook.deploy(ArchiveDep
| loyerHook.java:97)
| at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInt
| erceptor.java:90)
| at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.
| start(SubDeployerInterceptorSupport.java:188)
| at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterce
| ptor.java:95)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
| java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy34.start(Unknown Source)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
| at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
| sorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
| er.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
| or.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
| BeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
| java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy9.deploy(Unknown Source)
| at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
| tScanner.java:421)
| at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
| canner.java:610)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
| doScan(AbstractDeploymentScanner.java:263)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
| loop(AbstractDeploymentScanner.java:274)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
| run(AbstractDeploymentScanner.java:225)
| Caused by: java.io.FileNotFoundException: http://localhost:8080/tutorial/Calcula
| torBean?wsdl
| at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
| nection.java:1151)
| at java.net.URL.openStream(URL.java:1007)
| at org.jboss.ws.core.utils.ResourceURL.openStream(ResourceURL.java:57)
| at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.getDocument(WSDLDefini
| tionsFactory.java:166)
| ... 37 more
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147380#4147380
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147380
17 years, 11 months