[JBossWS] - Re: Problem with inheritance and JBossWS
by hannes.koller
I tried to post this in JIRA but it told me I dont have permission to comment on the issue so here it goes:
I am experiencing the same problem described by original Reporter: Subclass information gets lost when the SOAP message is created....but not always.. if the class contains a variable of JAXBElement then the inheritance seems to work correctly for all attributes in the class.
Example (constructed to explain my point, sorry if not 100% correct but the WSDL I am really dealing with is quite huge).
| <complexType name="SomeType">
| <complexContent>
| <sequence>
| <element name="someElement" type="tns:SomeElement" minOccurs="0" maxOccurs="1"nillable="true"/>
| <element name="classB" type="tns:ClassB" minOccurs="1" maxOccurs="1" nillable="true" />
| </sequence>
| </complexContent>
| </complexType>
|
Note that the minOccurrs="0" together with nillable="true" in someElement will cause wsconsume to create the JAXBElement<..> variable i was talking about:
| public class SomeType{
|
| @XmlElementRef(name = "someElement", namespace = "http://some.namespace.com", type = JAXBElement.class)
| protected JAXBElement<SomeElement> someElement;
| @XmlElement(required = true, nillable = true)
| protected ClassB classB;
| ....
|
In this example inheritance for the classB Attribute works as expected. Whereas if I alter the wsdl and set the minOccurrs of someElement to 1 thus having wsconsume create the following class:
| public class SomeType{
|
| @XmlElement(required=true, nillable=true)
| protected SomeElement someElement;
| @XmlElement(required = true, nillable = true)
| protected ClassB classB;
| ...
|
|
then inheritance on classB breaks.
Not sure why this is happening, but I thought this observation might help to track down the cause of this.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056371#4056371
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056371
18 years, 9 months
[JBossWS] - how to use jboss web service
by sdwfxsf
Hi,
I meet a problem when I use JBoss web service.
On client I use wsconsume to generate the java classes.
The code is:
ApplicationService.java
package greenback.esb.test;import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(name = "ApplicationService", targetNamespace = "http://test.esb.greenback/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface ApplicationService {
@WebMethod
@WebResult(partName = "return")
public String process(
@WebParam(name = "arg0", partName = "arg0")
Po arg0);
}
ApplicationServiceService.java
package greenback.esb.test;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
@WebServiceClient(name = "ApplicationServiceService", targetNamespace = "http://test.esb.greenback/", wsdlLocation = "http://192.168.168.188:8080/application/applicationESB?wsdl")
public class ApplicationServiceService
extends Service
{
private final static URL APPLICATIONSERVICESERVICE_WSDL_LOCATION;
static {
URL url = null;
try {
url = new URL("http://192.168.168.188:8080/application/applicationESB?wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
APPLICATIONSERVICESERVICE_WSDL_LOCATION = url;
}
public ApplicationServiceService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ApplicationServiceService() {
super(APPLICATIONSERVICESERVICE_WSDL_LOCATION, new QName("http://test.esb.greenback/", "ApplicationServiceService"));
}
@WebEndpoint(name = "ApplicationServicePort")
public ApplicationService getApplicationServicePort() {
return (ApplicationService)super.getPort(new QName("http://test.esb.greenback/", "ApplicationServicePort"), ApplicationService.class);
}
}
ObjectFactory.java
package greenback.esb.test;
import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the greenback.esb.test package.
* An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: greenback.esb.test
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link Po }
*
*/
public Po createPo() {
return new Po();
}
}
package-info.java
@javax.xml.bind.annotation.XmlSchema(namespace = "http://test.esb.greenback/")
package greenback.esb.test;
Po.java
package greenback.esb.test;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for po complex type.
*
* The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType name="po">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="age" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "po", propOrder = {
"age",
"name"
})
public class Po {
protected int age;
protected String name;
/**
* Gets the value of the age property.
*
*/
public int getAge() {
return age;
}
/**
* Sets the value of the age property.
*
*/
public void setAge(int value) {
this.age = value;
}
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
}
the wsdl file is
- <definitions name="ApplicationServiceService" targetNamespace="http://test.esb.greenback/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.esb.greenback/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <xs:schema targetNamespace="http://test.esb.greenback/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:complexType name="po">
- <xs:sequence>
<xs:element name="age" type="xs:int" />
<xs:element minOccurs="0" name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
-
-
-
-
-
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
-
<soap:operation soapAction="" />
-
<soap:body namespace="http://test.esb.greenback/" use="literal" />
-
<soap:body namespace="http://test.esb.greenback/" use="literal" />
-
-
<soap:address location="http://192.168.168.188:8080/application/applicationESB" />
The test class is
import greenback.esb.test.ApplicationService;
import greenback.esb.test.ApplicationServiceService;
import greenback.esb.test.Po;
public class Test {
public static void main(String[] args){
ApplicationServiceService ss=new ApplicationServiceService();
ApplicationService service=ss.getApplicationServicePort();
Po po=new Po();
po.setAge(12);
po.setName("init");
String s=service.process(po);
System.out.println(s);
}
}
Did I write the test class right?If it is not correct,what is the right way?
When I run the test Class ,it throws an exception
Exception in thread "Main Thread" org.jboss.remoting.CannotConnectException: Can not connect http client invoker.
at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:327)
at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:133)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
at org.jboss.remoting.Client.invoke(Client.java:1544)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.ws.core.soap.SOAPConnectionImpl.callInternal(SOAPConnectionImpl.java:192)
at org.jboss.ws.core.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:109)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:309)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:185)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:163)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:149)
at $Proxy13.process(Unknown Source)
at Test.main(Test.java:19)
Caused by: java.lang.ClassCastException: org.apache.axis.message.MessageElement
at org.jboss.ws.core.soap.SOAPEnvelopeImpl.(SOAPEnvelopeImpl.java:59)
at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:87)
at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:76)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:253)
at org.jboss.ws.core.soap.SOAPMessageUnMarshaller.read(SOAPMessageUnMarshaller.java:75)
at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:463)
at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:299)
... 12 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056271#4056271
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056271
18 years, 9 months
[JBossWS] - Soap Error : NAMESPACE_ERR: An attempt is made to create or
by amitkrsingh
Hello All,
I am getting following error when my stateless ejb makes a soap call to other server to load some static data. The soap call works fine outside the Jboss container and only when I try to make this call from within Jboss I get this error.
Also I wasnt expecting so see "org.jboss.ws.core.soap" in the stack trace, looks like somehow the SOAPContentElement class is being loaded from jbosall-cleintws.jar insted of the bundeled 'saaj' jars.
Any insight is welcome. This is my first soap experience so please bear with me if there is something very simple which I have overlooked.
Thanks in advance.
-Amit
/***ERROR*****/
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at org.apache.xerces.dom.CoreDocumentImpl.checkDOMNSErr(Unknown Source)
at org.apache.xerces.dom.AttrNSImpl.setName(Unknown Source)
at org.apache.xerces.dom.AttrNSImpl.(Unknown Source)
at org.apache.xerces.dom.CoreDocumentImpl.createAttributeNS(Unknown Source)
at org.apache.xerces.dom.ElementImpl.setAttributeNS(Unknown Source)
at org.jboss.ws.core.soap.SOAPElementImpl.setAttributeNS(SOAPElementImpl.java:747)
at org.jboss.ws.core.soap.SOAPContentElement.setAttributeNS(SOAPContentElement.java:409)
at org.jboss.ws.core.soap.SOAPElementImpl.addAttribute(SOAPElementImpl.java:174)
at org.jboss.ws.core.soap.SOAPContentElement.addAttribute(SOAPContentElement.java:280)
....
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
/******/
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056227#4056227
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056227
18 years, 9 months