You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 24 Members of 4546 |
| Forum: Seam Users |
30. Mar 2008, 18:21 CET | Link |
getting a http 405 a simple web services test .
I have a very simple test out to try and get WS running before piling into proper use - got stuck!
i am using a jboss tools SEAM project. I have a file called standard-jaxws-endpoint-config.xml in my xx-ejb META-INF directory as follows
<?xml version="1.0" encoding="UTF-8"?> <!-- webservice seam SOAP handler profile --> <jaxws-config xmlns="urn:jboss:jaxws-config:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="urn:jboss:jaxws-config:2.0 jaxws-config_2_0.xsd"> <endpoint-config> <config-name>Seam WebService Endpoint</config-name> <pre-handler-chains> <javaee:handler-chain> <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings> <javaee:handler> <javaee:handler-name>SOAP Request Handler</javaee:handler-name> <javaee:handler-class>org.jboss.seam.webservice.SOAPRequestHandler</javaee:handler-class> </javaee:handler> </javaee:handler-chain> </pre-handler-chains> </endpoint-config> </jaxws-config>
my test is then very easy heres the code .
package org.domain.wstest.webservices;
import java.util.List;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
import org.jboss.seam.Component;
@Stateless
@WebService (name="HelloService", serviceName="HelloService" )
public class HelloServiceBean implements HelloService
{
@WebMethod (operationName="sayHello")
@WebResult (name="helloResult")
public String hello ()
{
return "hello World";
}
}
when i deploy to the server, the server queitly creates the wsdl. I had to find it in the log - some theres probably someway to stipulate where you'd wish to put it. for me it put the wsdl in
E:\jboss\jboss-4.2.2.GA\server\default\data\wsdl\wstest2-ear.ear\wstest2-ejb.jar\HelloService17933.wsdl
i open the wsdl in a browser and i have following entry can be found near the bottom .
... - <service name="HelloService"> - <port name="HelloServicePort" binding="tns:HelloServiceBinding"> <soap:address location="http://127.0.0.1:8080/wstest2-ear-wstest2-ejb/HelloServiceBean" /> </port> </service>
I then start the ws explorer in eclipse and paste in the service location as noted above.
This then errors with
IWAB0379E Unable to open http://127.0.0.1:8080/wstest2-ear-wstest2-ejb/HelloServiceBean. IWAB0135E An unexpected error has occurred. WSDLException WSDLException: faultCode=OTHER_ERROR: Server returned HTTP response code: 405 for URL: http://127.0.0.1:8080/wstest2-ear-wstest2-ejb/HelloServiceBean
and i cant use my service -
what have i done wrong here ?
Go to http://127.0.0.1:8080/jbossws/ and check if the service is availible there. It should be.
okay - i went to the /jboss viewer as you mentioned.
I can see the service their - so i copied that url and pasted into the eclipse ws monitor and it worked better but not completly.
It can see the test method and formulates a SOAP packet to post - however the response doesnt work I get an error like this .
first heres the submitted request - I think this looks okay though there is no SOAP header generated in the window
the errored response from eclipse just shows
Not sure what this is trying to tell me - any ideas
and the error on the server console had the following error
Okay - i really dont think i understand how the web services bits work.
I have created a test client to see if i can call the webservice previously created - this is still published as a WSDL at
I then have a simple ejb project (so i can use dependency injection from a managed class to get my WS - cant get the eclipse WSDL explorer to work - see previous). like this
package test; import javax.ejb.Stateless; import javax.xml.ws.WebServiceRef; //included wstest2-ejb as depdent project to get import import org.domain.wstest2.webservices.HelloServiceBean; import org.domain.wstest2.webservices.*; @Stateless public class TestHelloBean implements TestHelloService, TestHelloServiceRemote { @WebServiceRef (HelloServiceBean.class) private HelloServiceBean helloService; public String sayHello() { String res = helloService.hello(); return res; } }I set the java build path for the ejb to include the wstest-ejb project (which is part of the wstest2-ejb project) that builds the webservice (that i cant use properly from eclipse wsdl explorer - see earlier errors)
This allows the code to compile (i've tried using an interface defn rather than the private HelloServiceBean attribute with similar failures)
when i deploy the ejb to the server it fails with NoClassDefFOundError see below.
The documentation I see in books or seam ref manual make this sound easy - sadly for mere mortals i dont find it so.
Can some one help me how to overcome this (both from eclipse wsdl viewer, and or test client using @webServiceRef
I really need to get this going as I have to expose some methods to a colleague on a test project - and cant proceed at present
Thanks in advance
22:52:33,362 WARN [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=wsTestClient.jar java.lang.NoClassDefFoundError: Lorg/domain/wstest2/webservices/HelloServiceBean; at java.lang.Class.getDeclaredFields0(Native Method) at java.lang.Class.privateGetDeclaredFields(Unknown Source) at java.lang.Class.getDeclaredFields(Unknown Source) at org.jboss.injection.InjectionUtil.processFieldAnnotations ... Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.domain.wstest2.webservices.HelloServiceBean at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212) at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521) at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 74 more 22:52:33,362 INFO [EJB3Deployer] Deployed: file:/E:/jboss/jboss-4.2.2.GA/server/default/deploy/wsTestClient.jar/ 22:52:33,362 ERROR [URLDeploymentScanner] Incomplete Deployment listing: --- Incompletely deployed packages --- org.jboss.deployment.DeploymentInfo@e2aae4cd { url=file:/E:/jboss/jboss-4.2.2.GA/server/default/deploy/wstest2-ear.ear/ } deployer: org.jboss.deployment.EARDeployer@523be status: null state: FAILED watch: file:/E:/jboss/jboss-4.2.2.GA/server/default/deploy/wstest2-ear.ear/ altDD: null lastDeployed: 1206913077322 lastModified: 1206913075720 mbeans: --- MBeans waiting for other MBeans --- ObjectName: jboss.j2ee:service=EJB3,module=wsTestClient.jar State: FAILED Reason: java.lang.NoClassDefFoundError: Lorg/domain/wstest2/webservices/HelloServiceBean; --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: jboss.j2ee:service=EJB3,module=wsTestClient.jar State: FAILED Reason: java.lang.NoClassDefFoundError: Lorg/domain/wstest2/webservices/HelloServiceBean;and here is the genderated WSDL from the EAR deploy
As with Shane, jboss ws would be your best bet.
I don't know if it helps, but did you run the ws scripts (in jboss home/bin) to create all of the necessary files? Your first error seems to indicate that this wasn't run.
Your second error is because the classes for your ws end up in a different classloader from your client.
starting from deploy dir, you have 2: client and server. client can't see server's classes, so you need a client for the server generated containing the stubs.
I recommend you ask on the JBossWS forums, there's nothing Seam-related within your issue as far as I can tell, and there's probably a lot more knowledgeable people there that can help you diagnose your problem. Once you get the basic web service working, then you can add Seam to the mix.
Nothing to do with your code. You're running on Java 1.6 and you're hitting a problem with incompatible JAXB implementations. The instructions say but that's not enough.
I posted a blog entry about setProperty must be overridden by all subclasses of SOAPMessage.