[JBoss Web Services] - @XMLElement(required = true) Validation
by Vincenzo Esposito
Vincenzo Esposito [http://community.jboss.org/people/vesposito] created the discussion
"@XMLElement(required = true) Validation"
To view the discussion, visit: http://community.jboss.org/message/600002#600002
--------------------------------------------------------------
Dear Community,
before anything thanks for all support.
Configuration:
JBoss 4.2.3.GA
JBossWS Native 3.1.0.GA
+I'm just developing a simple test usingWebService. I have some constraints to be applied to service’s parameters. In particular I’m looking for away to assure that the service provider receives only requests with valid input parameters.+
This is the service code:
TestService Interface
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.jws.soap.SOAPBinding.Style;
import org.jboss.wsf.spi.annotation.WebContext;
@WebContext(contextRoot="/TestService")
@WebService
@SOAPBinding(style= Style.DOCUMENT, parameterStyle = ParameterStyle.WRAPPED)
public interface TestService {
@WebMethod
public void sendInfo(TestObject to);
}
TestServiceBean
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.jboss.wsf.spi.annotation.WebContext;
@WebContext(contextRoot="/Test-Service")
@WebService(serviceName="TestService", endpointInterface="testing.TestService")
@Stateless
public class TestServiceBean implements TestService {
@WebMethod
public void sendInfo(TestObject to) {
System.out.println(to.get_data());
System.out.println(to.get_key());
}
}
TestObject Class
import javax.xml.bind.annotation.XmlElement;
public class TestObject {
private String _data;
private int _key;
@XmlElement(name = "_data", required = true)
public String get_data() {
return _data;
}
public void set_data(String _data) {
this._data = _data;
}
public int get_key() {
return _key;
}
public void set_key(int _key) {
this._key = _key;
}
}
+As you can see by code, analyzing TestObject class, Idecided that the "_data" attribute should be necessarly required and it must be not “nillable”. Once deployed, the generated WSDL is this one:+
TestServiceBean.wsdl
<definitions name="TestService" targetNamespace="http://testing/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://testing/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xs:schema targetNamespace="http://testing/" version="1.0" xmlns:tns="http://testing/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sendInfo" type="tns:sendInfo"/>
<xs:element name="sendInfoResponse" type="tns:sendInfoResponse"/>
<xs:complexType name="sendInfo">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:testObject"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testObject">
<xs:sequence>
<xs:element name="_data" type="xs:string"/>
<xs:element name="_key" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sendInfoResponse">
<xs:sequence/>
</xs:complexType>
</xs:schema>
</types>
<message name="TestService_sendInfoResponse">
<part element="tns:sendInfoResponse" name="sendInfoResponse"/>
</message>
<message name="TestService_sendInfo">
<part element="tns:sendInfo" name="sendInfo"/>
</message>
<portType name="TestService">
<operation name="sendInfo" parameterOrder="sendInfo">
<input message="tns:TestService_sendInfo"/>
<output message="tns:TestService_sendInfoResponse"/>
</operation>
</portType>
<binding name="TestServiceBinding" type="tns:TestService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sendInfo">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="TestService">
<port binding="tns:TestServiceBinding" name="TestServiceBeanPort">
<soap:address location="http://127.0.0.1:8180/Test-Service/TestServiceBean"/>
</port>
</service>
</definitions>
+Just analyzing the WSDL, I don't see anything about the "required" element, but using "wsconsume" tool I can obtain stubs to use client side. In detail, this is the generated TestObject stub+
Generated TestObject Stub detail
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "testObject", propOrder = {
"data",
"key"
})
public class TestObject {
@XmlElement(name = "_data", required = true)
protected String data;
@XmlElement(name = "_key")
protected int key;
.....
}
+The generated Stub contains the"required" constraint over the "_data" attribute.+
++
+In order to be consistent, I think that if Itry to use the TestObject omitting the "_data" value, JBossWS should not allow the service request. This is the client main method using to request the service.+
Main class
public static void main(String[] args) {
TestService_Service srv = new TestService_Service();
TestService test_srv = srv.getTestServiceBeanPort();
TestObject to = new TestObject();
to.setKey(3);
test_srv.sendInfo(to);
}
*+Running the client, it will perform the request without any Exception on its side and the "null" value for the "_data"attribute is received by service implementation.+*
++
+Now, what's wrong with the code? Is there anyexplaination about this issue? Why the WSDL do not contains the contraints over the "_data" value? Is there any validation before the SOAPMessage send?+
++
+Thank you for support again.+
++
+Vincenzo+
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/600002#600002]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years
[Datasource Configuration] - OracleValidConnectionChecker Unexpected error in pingDatabase
by Gunnar Bostrom
Gunnar Bostrom [http://community.jboss.org/people/gunnarbos] created the discussion
"OracleValidConnectionChecker Unexpected error in pingDatabase"
To view the discussion, visit: http://community.jboss.org/message/599108#599108
--------------------------------------------------------------
Hi,
We use JBoss 5.1.0.GA and java 1.6 and run in to trouble with org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker.
>From the log:
08:23:24,519 WARN [org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker] (http-0.0.0.0-8080-1) Unexpected error in pingDatabase
java.lang.IllegalArgumentException: object is not an instance of declaring class
This started to happen when I added
<!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered -->
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker
</valid-connection-checker-class-name>
to our oracle-ds.xml because we must check if the connection in the pool is valid.
The log says warning, but is the check done and a new connection created if the check failed?
Regards
Gunnar
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/599108#599108]
Start a new discussion in Datasource Configuration at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years
[EJB3] - org.jboss.ejb3.annotation.RemoteBinding on JBOSS4
by Tomasz Wolak
Tomasz Wolak [http://community.jboss.org/people/twolak] created the discussion
"org.jboss.ejb3.annotation.RemoteBinding on JBOSS4"
To view the discussion, visit: http://community.jboss.org/message/599934#599934
--------------------------------------------------------------
Hi:
I have been tasked with wipping out a small app using ejb3 and jsf on jboss. Having jboss 5 already up and running I coded it there first. The app is very simple: entity Bean together with Manager bean with local/remote interfaces. I used the org.jboss.ejb3.annotation.RemoteBinding to map my custom name of the manager bean. The manager bean was being accessed from JSF backing bean using direct injection. This setup worked great on Jboss5. However we currently use JBoss4 in production but I figured this will be a non issue just put the ear file in the Jboss4.x and off we go. Well not quite. I was aware of the fact that DI does not work in non container manager beans (such as JSF bean) so I used direct context lookup to account for this fact.
Here is stub for my manager:
import *org.jboss.ejb3.annotation*.LocalBinding;
import *org.jboss.ejb3.annotation*.RemoteBinding;
@RemoteBinding(jndiBinding = "FakeInvManager/remote")
@LocalBinding(jndiBinding = "FakeInvManager/local")
public class FakeInvManagerBean implements FakeInvManagerRemote,
FakeInvManagerLocal {
}
here is part of JSF where I look up the manager:
try {
Context envCtx = new InitialContext();
invMgr = (FakeInvManagerLocal) envCtx
.lookup("FakeInvManager/local");
} catch (NamingException ne) {
log.error("Cannot create instance of the FakeInvManager",
ne);
throw ne;
}
This is where it is getting intresting: I deployed this on JBOSS 4 and I had a failure ("FakeInvManager/local" not bound). Looked in the JNDI tree to find that the bean is not getting registered under "FakeInvManager/local". I could only use the global name "*earFileName/BeanName/local*". This meant that @LocalBinding is not working. Did a bit digging and found out that @LocalBinding implmentation changed from JBoss4 to JBoss5 from
org.jboss.annotation.ejb.LocalBinding;
to
org.jboss.ejb3.annotation.LocalBinding;
So I updated my manager to use JBoss4 (org.jboss.annotation.ejb.LocalBinding) implementation and everything went to normal i.e. I could look up the resource using the LocalBinding specified jndiBiding name (i.e. FakeInvManager/local").
You'd think that the story is over...problem solved?
Well here is my dilema: Originally I have deployed my manager Bean to JBOSS4.x using JBOSS5.x specific import:*org.jboss.ejb3.annotation.*LocalBinding;
Yet there is NO trace of that package on Jboss4.x so how come I did not explode with "ClassNotFound" or something to this account? In fact once I changed my lookup to the global JNDI biding the whole thing worked where I think it shouldn't?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/599934#599934]
Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years
[JNDI and Naming] - Re: javax.naming.CommunicationException
by Derya Altuntas
Derya Altuntas [http://community.jboss.org/people/deryaaltuntas] created the discussion
"Re: javax.naming.CommunicationException"
To view the discussion, visit: http://community.jboss.org/message/599924#599924
--------------------------------------------------------------
I am receiving same error.My client class is below.In lookup method Communication error exits.I will send print of JMX-Console service=Naming
screen.I see that my port is 1098.I am setting correct URL?
public class Test {
/**
* @param args
*/
public Test() {
}
public static void main(String[] args) throws FileNotFoundException, IOException, SecurityException{
Test searchFacadeTest = new Test();
searchFacadeTest.doTest();
}
public void doTest() throws FileNotFoundException, IOException{
try {
Context jndiContext = getInitialContext();
FileManagerBeanRemote fileManager= (FileManagerBeanRemote)jndiContext.lookup("FileManagerBean/remote");
//fileManager.moveFile("C:\\test.txt", "C:\\Documents and Settings\\tr1a6358\\bowling.txt");
}
catch (Exception e) {
e.printStackTrace();
}
}
// developed for JBoss only. this is vender dependency
public static Context getInitialContext( ) throws javax.naming.NamingException {
Properties p = new Properties( );
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://localhost:1098");
Context context = new InitialContext(p);
return context;
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/599924#599924]
Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years
[JBoss Web Services] - JBossWS - AS 7 FAQ
by Alessio Soldano
Alessio Soldano [http://community.jboss.org/people/asoldano] modified the document:
"JBossWS - AS 7 FAQ"
To view the document, visit: http://community.jboss.org/docs/DOC-16722
--------------------------------------------------------------
h1. JBossWS - AS 7 FAQ
This page is about the JBossWS integration with JBoss Application Server 7, which comes with a completely new architecture based on modules.
h4. Which modules belong to JBossWS? Am I supposed to modify them?
The org.jboss.as.webservices.* and org.jboss.ws.* modules belongs to the JBossWS - AS7 integration. Users should not need to change anything in them.
h4. I'm getting a ClassNotFoundException with an application that used to work on AS6, what's happening?
On JBoss AS7 the user deployment classloader does not have any visibility over JBoss internals; so for instance you can't directly use JBossWS +implementation+ classes unless you explicitly set a dependency to the corresponding module.
h4. How do I add dependencies to modules on my deployments?
Dependencies are configured in the deployment MANIFEST.MF file:
Manifest-Version: 1.0
Dependencies: org.jboss.ws.cxf.jbossws-cxf-client services export, foo.bar
Here above +org.jboss.ws.cxf.jbossws-cxf-client+ and +foo.bar+ are the module you want to set dependencies to; +services+ tells the modules framework that you want to also import +META-INF/services/..+ declarations from the dependency, while +export+ exports the classes in the module so that you can actually use them in your code.
h4. How can I use JAXB classes?
In order for successfully use JAXB contexts, etc. in your client or endpoint running in-container, you need to properly setup a JAXB implementation; that is performed setting the following dependency:
Dependencies: com.sun.xml.bind services export
h4. How can I use JBossWS APIs?
The JBossWS APIs are always available by default whenever the webservices subsystem is available on AS7. So you just use them.
h4. How can I use Apache CXF APIs?
In order for using Apache CXF APIs you need to add a dependency to the org.apache.cxf module:
Dependencies: org.apache.cxf
...however, please note that would not come with any JBossWS-CXF customizations nor additional extensions. See next FAQ.
h4. Is there an aggregation client side module with all WS dependencies?
Yes. Whenever you simply want to use all the JBossWS feature/functionalities, you can set a dependency to the convenient client module. For the JBossWS-CXF stack that's:
Dependencies: org.jboss.ws.cxf.jbossws-cxf-client services export
h4. What is the org.jboss.ws.jaxws-client module for?
That is the generic JAXWS client module that is internally loaded when the first call to the configured JAXWS Provider is performed. Depending on the configured ws stack, that pulls in the required modules for basic jaxws functionalities.
h4. How do I use Spring with JBossWS-CXF?
The JBossWS-CXF modules have optional dependencies to the +org.springframework.spring+ module. So either create that manually in the application server or use the JBossWS-CXF installation scripts for doing that.
h4. What SAAJ impl do I get doing MessageFactory.getFactory()?
...
--------------------------------------------------------------
Comment by going to Community
[http://community.jboss.org/docs/DOC-16722]
Create a new document in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&co...]
15 years
[JBoss Web Services] - JBossWS - AS 7 FAQ
by Alessio Soldano
Alessio Soldano [http://community.jboss.org/people/asoldano] modified the document:
"JBossWS - AS 7 FAQ"
To view the document, visit: http://community.jboss.org/docs/DOC-16722
--------------------------------------------------------------
h1. JBossWS - AS 7 FAQ
This page is about the JBossWS integration with JBoss Application Server 7, which comes with a completely new architecture based on modules.
h4. Which modules belong to JBossWS? Am I supposed to modify them?
The org.jboss.as.webservices.* and org.jboss.ws.* modules belongs to the JBossWS - AS7 integration. Users should not need to change anything in them.
h4. I'm getting a ClassNotFoundException with an application that used to work on AS6, what's happening?
On JBoss AS7 the user deployment classloader does not have any visibility over JBoss internals; so for instance you can't directly use JBossWS +implementation+ classes unless you explicitly set a dependency to the corresponding module.
h4. How do I add dependencies to modules on my deployments?
Dependencies are configured in the deployment MANIFEST.MF file:
Manifest-Version: 1.0
Dependencies: org.jboss.ws.cxf.jbossws-cxf-client services export, foo.bar
Here above +org.jboss.ws.cxf.jbossws-cxf-client+ and +foo.bar+ are the module you want to set dependencies to; +services+ tells the modules framework that you want to also import +META-INF/services/..+ declarations from the dependency, while +export+ exports the classes in the module so that you can actually use them in your code.
h4. How can I use JAXB classes?
In order for successfully use JAXB contexts, etc. in your client or endpoint running in-container, you need to properly setup a JAXB implementation; that is performed setting the following dependency:
Dependencies: com.sun.xml.bind services export
h4. How can I use JBossWS APIs?
...
h4. How can I use Apache CXF APIs?
...
h4. Is there an aggregation client side module with all WS dependencies?
...
h4. What is the org.jboss.ws.jaxws-client module for?
...
h4. How do I use Spring with JBossWS-CXF?
...
h4. What SAAJ impl do I get doing MessageFactory.getFactory()?
...
--------------------------------------------------------------
Comment by going to Community
[http://community.jboss.org/docs/DOC-16722]
Create a new document in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&co...]
15 years