[JBossWS] - NoSuchMethodError in clientside of a jaxws ws
by santhoshitha
Hi,
I am using jbossws1.2.0 on jboss as 4.0.5, and jdk 1.6.0. i have a web service that contains methods that accept arrays of custom classes as one of its parameters, and returns an array of strings. in the wsdl generated i see that separate classes are generated for the arrays of the custom objects and strings. objects of these classes are instead taken as parameters from the client. basically the wsdl contains separate complextypes created for the arrays of the custom objects and strings. when i do a wsdl to java generation on the client i see an sei and a service class that contains a get(service)port method. apart from these there are namespace and package mapping classes.
i would like to use a static stub at the client side, since my client is a standalone java app, that acts as an adapter and interacts with other apps in my organization. how do i get a static stub that implements the sei on the clientside using the jaxws tools provided by jboss? as of now i have a cleint that tries to obtain the port by instanciating the service class and invoking the webservice method. since there is no impl on the client side, i get a NoSuchMethodError.
i have also tried using the dynamic proxy invocation from my client and get an exception there too. the exception reads, Cannot obtain java type mapping for: {http://datamodel.nm_update}securityAttributesArray, where http://datamodel.nm_update is my target namespace and securityAttributeArray is the complex type generated in the wsdl for the array of custom objects, which is the webservice method's parameter.
below is a section of the wsdl generated for my ws.
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="NmUpdateService_Service" targetNamespace="http://datamodel.nm_update" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://jaxb.dev.java.net/array" xmlns:tns="http://datamodel.nm_update" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<xs:schema targetNamespace="http://jaxb.dev.java.net/array" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType final="#all" name="stringArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema targetNamespace="http://datamodel.nm_update" version="1.0" xmlns:tns="http://datamodel.nm_update" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="securityAttributes">
<xs:sequence>
<xs:element minOccurs="0" name="colName" type="xs:string"/>
<xs:element name="index" type="xs:int"/>
<xs:element name="spn" type="xs:int"/>
<xs:element minOccurs="0" name="value" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType final="#all" name="securityAttributesArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns:securityAttributes"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
the java name of the webservice method is updateAttributes, and wsdl name is NmUpdateService_updateAttributesResponse.
1) could the nosuchmethoderror be because of incomplete/wrong mapping of type names from wsdl to java?
2) what could the reason for the inability to map between the securityattributesarray object from to java to wsdl be during invocation from the client?
3)will the provider and dispatch APIs help in any way for dynamic invocation?
any help is much appreciated. thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031266#4031266
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031266
19 years
[JBossWS] - Re: Providing your own wsdl instead of the generated one.
by ngtdave
Just to be clear which versions I'm using:
Boss 4.2.0.CR1
jbossws-1.2.0.GA (build=200703010320)
java 1.5.0_11-b03
Here are the final files.
EchoService.wsdl (note the \<documentation\> tag near the bottom)
<?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>
web.xml (note <servlet-class> specifies the imple):
<?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.EchoImpl</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>echo</servlet-name>
| <url-pattern>/*</url-pattern>
| </servlet-mapping>
|
| </web-app>
Echo.java (note wsdlLocation added by hand to @WebService)
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);
|
| }
|
and finally EchoImpl.java (not the portName)
package echo;
|
| @javax.jws.WebService(endpointInterface="echo.Echo", portName="EchoPort")
| public class EchoImpl implements Echo
| {
| public String echo(String arg0)
| {
| return arg0;
| }
| }
And for completeness, the war structure
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031124#4031124
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031124
19 years
[JBossWS] - Re: Providing your own wsdl instead of the generated one.
by ngtdave
Alright, I got it working.
First I changed my web.xml to use the impl bean:
<servlet-class>echo.EchoImpl</servlet-class>
per this discussion:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=70837
where Diesler says:
anonymous wrote : So this is trying to instanciate an interface. Your web.xml should contain the endpoint impl bean not the SEI. Is that the case?
but then I got this error:
9:55:24,824 ERROR [ServiceEndpointDeployer] Cannot create service endpoint
| rg.jboss.ws.WSException: Cannot find port in wsdl: {http://echo/}EchoImplPort
So then I remembered:
https://jax-ws.dev.java.net/jax-ws-ea3/docs/annotations.html#2.1%20javax....
specifies:
anonymous wrote : javax.jws.WebService.portName - The wsdl:portName
So I tried to change Echo.java to declare the port, but I got an error:
09:56:05,683 ERROR [MainDeployer] Could not create deployment: file:/D:/jboss/jboss-4.2.0.CR1/server/default/deploy/echo.war
| org.jboss.deployment.DeploymentException: Cannot create service endpoint; - nested throwable: (org.jboss.ws.WSException: @WebService[portName,serviceName,endpoi
| ntInterface] MUST NOT be defined on: echo.Echo)
So I changed EchoImple.java:
@javax.jws.WebService(endpointInterface="echo.Echo",portName="EchoPort")
| public class EchoImpl implements Echo
| ....
|
Now it works and it still serves out my wsdl.
I'm not sure if this is a bug or not because the docs here https://jax-ws.dev.java.net/jax-ws-ea3/docs/annotations.html#2.1%20javax....
say:
anonymous wrote : endpointInterface - The qualified name of the service endpoint interface. This annotation allows the separation of interface contract from implementation. If this property is specified, all other WebService properties are ignored as are all other 181 annotations. Only the annotations on the service endpoint interface will be taken into consideration. The endpoint implementation class is not required to implement the endpointInterface.
Which I take to mean the other parameters (portName) should be ignored if endpointInterface is specified.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031115#4031115
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031115
19 years