[JBossWS] - Providing your own wsdl instead of the generated one.
by ngtdave
Alright, it took me a long time to put all the pieces together after searching the forums and jira. If you want to serve up your own wsdl instead of the generated one you do the following:
In the interface you specify the wsdlLocation:
@WebService(name = "Echo", targetNamespace = "http://echo/", wsdlLocation="META-INF/wsdl/EchoService.wsdl")
|
Then when you package your war file, you put the wsdl in the META-INF/wsdl directory of your war.
I apologize if this is obvious, but it took me a while to figure out.
Here is the full working example using top-down design:
First I started with EchoService.wsdl
<?xml version="1.0" encoding="UTF-8"?>
| <definitions name='EchoService' targetNamespace='http://echo/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://echo/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
| <types>
| <xs:schema targetNamespace='http://echo/' version='1.0' xmlns:tns='http://echo/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
| <xs:element name='echo' type='tns:echo'/>
| <xs:element name='echoResponse' type='tns:echoResponse'/>
| <xs:complexType name='echo'>
| <xs:sequence>
| <xs:element minOccurs='0' name='arg0' type='xs:string'/>
| </xs:sequence>
| </xs:complexType>
| <xs:complexType name='echoResponse'>
| <xs:sequence>
| <xs:element minOccurs='0' name='return' type='xs:string'/>
| </xs:sequence>
| </xs:complexType>
| </xs:schema>
| </types>
| <message name='Echo_echo'>
| <part element='tns:echo' name='echo'/>
| </message>
| <message name='Echo_echoResponse'>
| <part element='tns:echoResponse' name='echoResponse'/>
| </message>
| <portType name='Echo'>
| <operation name='echo' parameterOrder='echo'>
| <input message='tns:Echo_echo'/>
| <output message='tns:Echo_echoResponse'/>
| </operation>
| </portType>
| <binding name='EchoBinding' type='tns:Echo'>
| <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
| <operation name='echo'>
| <soap:operation soapAction=''/>
| <input>
| <soap:body use='literal'/>
| </input>
| <output>
| <soap:body use='literal'/>
| </output>
| </operation>
| </binding>
| <service name='EchoService'>
| <documentation>Congrats! You have published your own WSDL!</documentation>
| <port binding='tns:EchoBinding' name='EchoPort'>
| <soap:address location='REPLACE_WITH_ACTUAL_URL'/>
| </port>
| </service>
| </definitions>
Then I generated the java files using wsconsume:
$ wsconsume -k EchoService.wsdl
| echo/Echo.java
| echo/EchoResponse.java
| echo/EchoService.java
| echo/Echo_Type.java
| echo/ObjectFactory.java
| echo/package-info.java
| echo/Echo.java
| echo/EchoResponse.java
| echo/EchoService.java
| echo/Echo_Type.java
| echo/ObjectFactory.java
| echo/package-info.java
I promptly threw away EchoService.java because it's really for the client, not the server.
Next I implemented EchoImpl.java
package echo;
|
| @javax.jws.WebService(endpointInterface="echo.Echo")
| public class EchoImpl implements Echo
| {
| public String echo(String arg0)
| {
| return arg0;
| }
| }
Then I edited Echo.java and added wsdlLocation (bolded below)
package echo;
|
| import javax.jws.WebMethod;
| import javax.jws.WebParam;
| import javax.jws.WebResult;
| import javax.jws.WebService;
| import javax.xml.ws.RequestWrapper;
| import javax.xml.ws.ResponseWrapper;
|
|
| /**
| * JBossWS Generated Source
| * ....
| * JAX-WS Version: 2.0
| *
| */
| @WebService(name = "Echo", targetNamespace = "http://echo/", wsdlLocation="META-INF/wsdl/EchoService.wsdl")
| public interface Echo {
|
|
| /**
| *
| * @param arg0
| * @return
| * returns java.lang.String
| */
| @WebMethod
| @WebResult(targetNamespace = "")
| @RequestWrapper(localName = "echo", targetNamespace = "http://echo/", className = "echo.Echo_Type")
| @ResponseWrapper(localName = "echoResponse", targetNamespace = "http://echo/", className = "echo.EchoResponse")
| public String echo(
| @WebParam(name = "arg0", targetNamespace = "")
| String arg0);
|
| }
|
Next I created a web.xml:
<?xml version="1.0" encoding="UTF-8"?>
|
| <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>echo</servlet-name>
| <servlet-class>echo.Echo</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>echo</servlet-name>
| <url-pattern>/*</url-pattern>
| </servlet-mapping>
|
| </web-app>
|
Then I packed them up into a echo.war:
META-INF/
| META-INF/MANIFEST.MF
| META-INF/wsdl/
| META-INF/wsdl/EchoService.wsdl
| WEB-INF/
| WEB-INF/classes/
| WEB-INF/classes/echo/
| WEB-INF/classes/echo/Echo.class
| WEB-INF/classes/echo/EchoImpl.class
| WEB-INF/classes/echo/EchoResponse.class
| WEB-INF/classes/echo/Echo_Type.class
| WEB-INF/classes/echo/ObjectFactory.class
| WEB-INF/classes/echo/package-info.class
| WEB-INF/web.xml
Then I dropped it into the deploy directory.
When I looked at the log file, I saw it deployed my wsdl:
07:39:03,777 INFO [TomcatDeployer] deploy, ctxPath=/echo, warUrl=.../tmp/deploy/tmp45417echo-exp.war/
| 07:39:04,839 INFO [WSDLFilePublisher] WSDL published to: file:/D:/jboss/jboss-4.2.0.CR1/server/default/data/wsdl/echo.war/EchoService.wsdl
| 07:39:04,886 INFO [ServiceEndpointManager] WebService started: http://127.0.0.1:8080/echo
Instead of what it did when I didn't properly specify the wsdlLocation:
07:10:04,777 INFO [TomcatDeployer] undeploy, ctxPath=/echo, warUrl=.../tmp/deploy/tmp45397echo-exp.war/
| 07:10:06,449 INFO [TomcatDeployer] deploy, ctxPath=/echo, warUrl=.../tmp/deploy/tmp45400echo-exp.war/
| 07:10:06,730 INFO [WSDLFilePublisher] WSDL published to: file:/D:/jboss/jboss-4.2.0.CR1/server/default/data/wsdl/echo.war/EchoService45401.wsdl
Sure enough, going to http://127.0.0.1:8080/echo?wsdl displayed my wsdl, not the generated one.
Hope this helps some of you out there.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031052#4031052
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031052
19Â years, 1Â month
[JBoss Portal] - Re: how to get reqest parameter [multi lang -for Big5 (ta
by kevnlin
21:35:11,498 INFO [STDOUT] opmode=add
21:35:18,514 INFO [STDOUT] UTF-8 this is out.println req.getCharacterEncoding());
21:35:18,522 INFO [STDOUT] [B@1150ef8
21:35:18,523 INFO [STDOUT] ??? first print
21:35:18,733 INFO [STDOUT] ???EDIT
21:35:18,735 INFO [STDOUT] opmode=addup
21:35:18,756 INFO [STDOUT] 070323213518
21:35:18,757 INFO [STDOUT] ???
21:35:18,758 INFO [STDOUT] ???
21:35:18,758 INFO [STDOUT] Fri Mar 23 21:35:18 CST 2007
21:35:18,759 INFO [STDOUT] ???
21:35:18,759 INFO [STDOUT] Y
21:35:20,185 INFO [STDOUT] ???VIEW
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031049#4031049
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031049
19Â years, 1Â month
Problem with multiple jar version and classloading
by Olivier Fabre - EBM WebSourcing
Hi,
I wanna deploy a Wep App that makes use of commons-httpclient jar
version 3.0.1. The problem is that an other version of
commons-httpclient jar (version 2.0.2) is already present in
JBossRoot/lib and in JBossRoot/server/default/lib. These two versions of
the jar contains the same class
(org.apache.commons.httpclient.HttpConnectionManager) but with different
methods. So my web app throw the following exception :
java.lang.NoSuchMethodError:
org.apache.commons.httpclient.HttpConnectionManager.getParams()
Is it possible to configure web app classloading to avoid this type of
error ?
Thanks
Regards,
Olivier
19Â years, 1Â month