[JBossWS] - Marshalling
by vitor_b
Hello
Since there is no user forum dedicated for unmarshalling and marshalling problems i think this is the best place where i can ask question related to these topics.
Ususally our Webservice get xml document, unmarshall it, do some business logic, then marshall result and send it to caller. Marshalling and unmarshalling are done automatically.
Now i would like to marshall my output object manually. I have my object and xml schema. It looks like i have everything i need. But i really don't know how to do it. There should be very simple API enables that funcionality. But i found two things: JbossXB and JAXB.
1. JbossXB
There is a big problem. For every class we want to marshall we need class which implements interface ObjectModelProvider. I've taken a look at example: http://wiki.jboss.org/wiki/Wiki.jsp?page=ObjectModelProvider
Provider classes are not very simple. And my output is much more complex that that one used in this example. I have no time to write so many Providers for my classes. Besides of lack of time there is one more importnat reason. This object can be changed.
Unfortunately there is no other way to marshall with JbossXb using my xml schema.
2. JAXB
This is the second way i know. But examples i saw need so many generated classes and interfaces. This is not a problem. But where generating all this stuff interfaces and business classes are also generated. These classes are used for marshalling. But i have my own business classes, and these ones don't implements so many interfaces like:
com.sun.xml.bind.RIElement, com.sun.xml.bind.JAXBObject, primer.po.impl.runtime.UnmarshallableObject, primer.po.impl.runtime.XMLSerializable, primer.po.impl.runtime.ValidatableObject
So my one question is; how to mashall my business doc using my xml schema? Is there way to do that?
Any sugestions are really welcome, becouse i'm really lost.
Thank you in advance.
vitor_b
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031536#4031536
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031536
17 years, 9 months
[JBossWS] - Re: beginner needs help
by vitor_b
Sorry for such a long time you had to wait for my reply.
First thing you need is: JWSDP (Java Web Services Developer Pack). You can download it from www.sun.com. I use jwsdp-1.4.
And here it is ant task which will generate for you jaxrpc-mapping and wsdl files:
First we need to set path to JWSDP:
<property name="jwsdp.dir" value="<your path>\jwsdp-1.4" />
| <property name="classes.dir" value="<compiled classes>\bin" />
Replace values in <> to your specific ones.
Now we have to specify jar libraries we will use:
<path id="jwsdp.lib.path">
| <fileset dir="${jwsdp.dir}/jwsdp-shared">
| <include name="**/*.jar"/>
| </fileset>
|
| <fileset dir="${jwsdp.dir}/jaxrpc">
| <include name="**/*.jar"/>
| </fileset>
|
| <fileset dir="${jwsdp.dir}/saaj">
| <include name="**/*.jar"/>
| </fileset>
| </path>
We need one more library (we need class com.sun.tools.javac.Main):
<path id="wscompile.task.classpath">
| <path refid="jwsdp.lib.path"/>
| <fileset dir="${java.home}/../lib" includes="tools.jar"/>
| </path>
Now we define our own ant task:
<taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile" classpathref="wscompile.task.classpath"/>
And we run it:
<target name="run-wscompile" depends="xdoclet-build">
| <wscompile base="${res-generated-dir}"
| fork="true"
| server="true"
| features="rpcliteral"
| mapping="${res-gen-ws}/jaxrpc-mapping.xml"
| config="${res-hand-made-dir}/wscompile-config.xml"
| nonClassDir="${res-gen-ws}">
|
| <classpath>
| <path refid="wscompile.task.classpath"/>
| <pathelement location="${classes.dir}"/>
| </classpath>
|
| </wscompile>
| </target>
res-gen-ws and res-hand-made-dir are my dirs.
res-gen-ws is the directory which will contain generated jaxrpc-mapping and wsdl files. But wscompile task needs one more thing: wscompile-config.xml
This file contains info which will be used for generating files for you.
My file looks like that:
<?xml version="1.0" encoding="UTF-8"?>
| <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
| <service name="NameWebService"
| targetNamespace="http://localhost:8080/jmsprototype"
| typeNamespace="http://localhost:8080/jmsprototype/types"
| packageName="ws.bean">
| <interface name="ws.bean.WebService"/>
| </service>
| </configuration>
packageName - package contains web service classes
Element interface contains WebService class, that implements interface java.rmi.Remote.
service name - name for service in wsdl file
<service name="NameWebService">
You still have to create webservices.xml file yourself. But that is not a very hard thing to do.
If you have any questions just ask.
I will check this topic later.
Take care
vitor_b
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031523#4031523
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031523
17 years, 9 months
[JBossWS] - Problem to trace SOAP Message when an exception occures!
by manosurf
Hi,
In order to see the SOAP Message I developped my Handler that extends GenericHandler.
Bellow the extract code of my Handler
public boolean handleRequest(MessageContext msgContext){
try {
SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
soapMessage.writeTo(System.out);
}
catch (Exception e){
// to do
}
return true;
}
public boolean handleResponse(MessageContext msgContext) {
try{
SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
soapMessage.writeTo(System.out);
}
catch (Exception e) {
// to do
}
return true;
}
Globally I can see the SOAP message in the stdout console,
but when my method throws my UserException it happens two things :
- I don't the see the SOAP message in the stdout. that means that the handleResponse method has never called. why ?
- I see the following Execption in the stdout console but the client application receive well formatted SOAP Message with the Fault.
10:05:24,586 ERROR [SOAPFaultHelperJAXRPC] SOAP request exception
com.eservglobal.topupapi.ComplexUserException: user is equals to password
at com.eservglobal.topupapi.TopupServiceBean.login(TopupServiceBean.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
How can I do to :
- catch the SOAP message in my Hanlder to trace SOAP Message ?
- avoid that JBOSS traces the stack Exception in the stdout console ?
Can you help me?
Best Regards.
manosurf
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031495#4031495
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031495
17 years, 9 months
[JBossWS] - Accessing a secure WSDL
by PeterJ
I have implemented the Echo web service, and client, described at http://jbws.dyndns.org/mediawiki/index.php/JAX-WS_User_Guide#Bottom-Up_.2.... Once those were working, I added BASIC authentication to the web service by adding the following to the web.xml:
<security-constraint>
| <web-resource-collection>
| <web-resource-name>Secure Echo</web-resource-name>
| <url-pattern>/Echo</url-pattern>
| </web-resource-collection>
| <auth-constraint>
| <role-name>friend</role-name>
| </auth-constraint>
| </security-constraint>
| <login-config>
| <auth-method>BASIC</auth-method>
| <realm-name>JBossWS</realm-name>
| </login-config>
| <security-role>
| <role-name>friend</role-name>
| </security-role>
and I added a jboss-web.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
| <jboss-web>
| <security-domain>java:/jaas/JBossWS</security-domain>
| </jboss-web>
After deploying the web service, I can access the WSDL through a browser after I enter the user name and password in the pop-up dialog box.
However, I then ran into several problems:
1) How do I run wsconsume against this WSDL? There does not appear to be any mechanism to pass the user name and password to wsconsume.
2) I modified my client to set the user name and password on the BindingProvider before I call echo(), but the client fails earlier on because that same BindingProvider information is not used when the WSDL is obtained. I looked at the org.jboss.test.ws.jaxws.samples.context.WebServiceContextJSETestCase class, but it cheats - it gets the WSDL from the file system, not via HTTP.
I tried adding the annotation @WebContext(secureWSDLAccess = false) to the Echo class, and deployed it again, but even though the sever.log indicates that it picked up this setting, my browser still wants a user name and password to access the WSDL, and of course wsconsume and the client still fail (with 401 errors).
So my question: how do I go about setting the user name and password when requesting the WSDL via wsconsume or client code?
JBoss AS 5.0.0 beta2 (pulled on Mar 10)
JBoss WS 1.2.0.GA
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031441#4031441
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031441
17 years, 9 months
[JBossWS] - Re: WSDL-location help?
by zauberlehrling
The JSR181 specification (http://jcp.org/en/jsr/detail?id=181) says in 4.1 Annotation: javax.jws.WebService:
anonymous wrote : wsdlLocation:
| The location of a pre-defined WSDL
| describing the service. The wsdlLocation is
| a URL (relative or absolute) that refers to a
| pre-existing WSDL file. The presence of a
| wsdlLocation value indicates that the
| service implementation bean is implementing
| a pre-defined WSDL contract. The JSR-181
| tool MUST provide feedback if the service
| implementation bean is inconsistent with the
| portType and bindings declared in this
| WSDL. Note that a single WSDL file might
| contain multiple portTypes and multiple
| bindings. The annotations on the service
| implementation bean determine the specific
| portType and bindings that correspond to
| the Web Service.
My interpretation is that something like
| @Webservice(..
| wsdlLocation="http:\\ .. "
| ..)
|
should be possible.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031348#4031348
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031348
17 years, 9 months