You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Wierenga, R. - SPLXE" <Ro...@klm.com> on 2004/08/11 15:26:42 UTC

axis 1.1 and jaxb

Hi !

I'm trying to use jaxb as the (de)serialization mechanism for the provision
of a document/literal style webservice. Has anyone succeeded in implementing
this? I'm curious to know which steps i need to take.

Steps i took so far are:
* created a wsdl file including the schema for my complextypes
* used axis wsdl2java tool to generate the skeleton, implementation and
beans sources
* created a custom JAXB serializer based on Castor serializer example
* modified wsdd to use the new JAXB serializer for each compleyType and
element defined in the schema
* deployed stuff using adminclient
* tested results using WSAD 5.1 Webservice explorer

Problems which i encountered:
* A call to the webservice results in a Soap fault
(java.lang.reflect.InvocationTargetException)
* The wsdl file generated by Axis after deployment is invalid, it does not
contain the complexType definitions which were defined in the original wsdl.
How could this happen? When I leave out the type mappings in my deploy.wsdd
and redeploy it produces a valid wsdl file...strange.


Kinds regards,
Robin Wierenga


**********************************************************************
For information, services and offers, please visit our web site: http://www.klm.com. This e-mail and any attachment may contain confidential and privileged material intended for the addressee only. If you are not the addressee, you are notified that no part of the e-mail or any attachment may be disclosed, copied or distributed, and that any other action related to this e-mail or attachment is strictly prohibited, and may be unlawful. If you have received this e-mail by error, please notify the sender immediately by return e-mail, and delete this message. Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its employees shall not be liable for the incorrect or incomplete transmission of this e-mail or any attachments, nor responsible for any delay in receipt.
**********************************************************************


X509Trust Manager and SOAP

Posted by Pravir Ramtekkar <pr...@nms.fnc.fujitsu.com>.
Hi,
I saw the following post on the internet and thought anybody in the AXIS 
community would have the answer I am looking for.
I also have the same question. Using my TrustManager I connect to any 
https server ( HTTPSConnection) it works great and I can download 
content but when I do the same using soap it throws the same exception ( 
No Valid Ceritificate found)
I am using WSDL2Java from apache to generate stubs and using the 
generated locator to connect to the service.

If you've got an answer to this, would appreciate sending that to  me.

same as your case, I dont want to import the certificate into a store 
and specify keystore/password etc.
-thanx,

********************************
Subject: custom x509trustmanager with SOAP

View this article only
Newsgroups: comp.lang.java.security
Date: 2003-07-30 11:13:48 PST

Like others I've seen lots of people asking similar question, and
nobody answers, so this must be one of the great unknowns, but just to
try every avenue, I thought I'd post a message.

I am trying to make a soap call over ssl. Apache's soap library, ibm
websphere 5.

Soap works great over http.
When I do https, I do the
System.setProperty("java.protocol.handler.pkgs","com.ibm.net.ssl.internal.www.protocol");
to get "https"  to be recognised.
I do Security.addProvider(new com.ibm.jsse.IBMJSSEProvider()); to add
the ssl provider.
But then of course, I get the dreaded unknown certificate error. No, I
can not add the certificate to my trust store.
So I implement my own trust store...
public class TrustEverybody implements X509TrustManager
All functions return true.

Now everybody else has the problem of registering their trustmanager
with the context that they make their ssl socket connection from.

That's not my problem, mine's even better. I'm making a soap call,
remember? I'm not the one making the socket. The apache soap library
is.
So I need some way to shove my ssl context into the soap library, or
if I could make the connection myself, (having already registered my
trustmanager) hand it off to the SOAP library.
I tried this:
HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
I was hoping this was a global static that all https calls went
through, (ctx being the context I set up using my custom trust
manager) but it doesn't work. my trustmanager never gets called.

I can only assume that lots of people are going to get to this page
beacuse of the subject, because lots of people have this problem, and
there are very few answers and they don't apply to my problem.

I can only hope there is a god out there somewhere who can miracle me
an answer before this is due, last friday.



X509Trust Manager and SOAP

Posted by Pravir Ramtekkar <pr...@nms.fnc.fujitsu.com>.
Hi,
I saw the following post on the internet and thought anybody in the AXIS 
community would have the answer I am looking for.
I also have the same question. Using my TrustManager I connect to any 
https server ( HTTPSConnection) it works great and I can download 
content but when I do the same using soap it throws the same exception ( 
No Valid Ceritificate found)
I am using WSDL2Java from apache to generate stubs and using the 
generated locator to connect to the service.

If you've got an answer to this, would appreciate sending that to  me.

same as your case, I dont want to import the certificate into a store 
and specify keystore/password etc.
-thanx,

********************************
Subject: custom x509trustmanager with SOAP

View this article only
Newsgroups: comp.lang.java.security
Date: 2003-07-30 11:13:48 PST

Like others I've seen lots of people asking similar question, and
nobody answers, so this must be one of the great unknowns, but just to
try every avenue, I thought I'd post a message.

I am trying to make a soap call over ssl. Apache's soap library, ibm
websphere 5.

Soap works great over http.
When I do https, I do the
System.setProperty("java.protocol.handler.pkgs","com.ibm.net.ssl.internal.www.protocol");
to get "https"  to be recognised.
I do Security.addProvider(new com.ibm.jsse.IBMJSSEProvider()); to add
the ssl provider.
But then of course, I get the dreaded unknown certificate error. No, I
can not add the certificate to my trust store.
So I implement my own trust store...
public class TrustEverybody implements X509TrustManager
All functions return true.

Now everybody else has the problem of registering their trustmanager
with the context that they make their ssl socket connection from.

That's not my problem, mine's even better. I'm making a soap call,
remember? I'm not the one making the socket. The apache soap library
is.
So I need some way to shove my ssl context into the soap library, or
if I could make the connection myself, (having already registered my
trustmanager) hand it off to the SOAP library.
I tried this:
HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
I was hoping this was a global static that all https calls went
through, (ctx being the context I set up using my custom trust
manager) but it doesn't work. my trustmanager never gets called.

I can only assume that lots of people are going to get to this page
beacuse of the subject, because lots of people have this problem, and
there are very few answers and they don't apply to my problem.

I can only hope there is a god out there somewhere who can miracle me
an answer before this is due, last friday.



Re: axis 1.1 and jaxb

Posted by Paul Callahan <ca...@gmail.com>.
Hi,

An alternative to creating a custom serializer is to use the
doc/literal style service and use one of the 4 method signatures that
Axis allows.  You can inspect the incoming XML to determine what kind
of message you have received.  From there, use the utilities provided
by the JAXB api to translate the XML message into JAXB objects, and
perform your business logic.  Then, create output objects using JAXB
and serialize them to XML--return that from your web service method. 
So your webservice "controller" class could have a method like this:

public Document doService(Document body) throws AxisFault {

  // inspect the document to see what "kind" of message you have received..
  
  // deserialize the message
  jc = JAXBContext.newInstance(<your namespace>);
  u = jc.createUnmarshaller();
  m = jc.createMarshaller();
  requestObj = u.unmarshal(body);

  // perform your domain logic on this object

  // serialize and return your response
  returnDoc = XMLUtils.newDocument();
  m.marshal(responseObj, returnDoc);

   return returnDoc;

}

Sounds like creating a custom serializer would be cleaner, however. 
Have you been able to debug this InvocationTarget problem?

-pc 

On Wed, 11 Aug 2004 15:26:42 +0200, Wierenga, R. - SPLXE
<ro...@klm.com> wrote:
> Hi !
> 
> I'm trying to use jaxb as the (de)serialization mechanism for the provision
> of a document/literal style webservice. Has anyone succeeded in implementing
> this? I'm curious to know which steps i need to take.
> 
> Steps i took so far are:
> * created a wsdl file including the schema for my complextypes
> * used axis wsdl2java tool to generate the skeleton, implementation and
> beans sources
> * created a custom JAXB serializer based on Castor serializer example
> * modified wsdd to use the new JAXB serializer for each compleyType and
> element defined in the schema
> * deployed stuff using adminclient
> * tested results using WSAD 5.1 Webservice explorer
> 
> Problems which i encountered:
> * A call to the webservice results in a Soap fault
> (java.lang.reflect.InvocationTargetException)
> * The wsdl file generated by Axis after deployment is invalid, it does not
> contain the complexType definitions which were defined in the original wsdl.
> How could this happen? When I leave out the type mappings in my deploy.wsdd
> and redeploy it produces a valid wsdl file...strange.
> 
> Kinds regards,
> Robin Wierenga
> 
> **********************************************************************
> For information, services and offers, please visit our web site: http://www.klm.com. This e-mail and any attachment may contain confidential and privileged material intended for the addressee only. If you are not the addressee, you are notified that no part of the e-mail or any attachment may be disclosed, copied or distributed, and that any other action related to this e-mail or attachment is strictly prohibited, and may be unlawful. If you have received this e-mail by error, please notify the sender immediately by return e-mail, and delete this message. Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its employees shall not be liable for the incorrect or incomplete transmission of this e-mail or any attachments, nor responsible for any delay in receipt.
> **********************************************************************
> 
>

Re: axis 1.1 and jaxb

Posted by Elliot Metsger <em...@jhu.edu>.
Hi Robin!

I'm interested in going down this road, but you're farther along then I.

Wierenga, R. - SPLXE wrote:

> Steps i took so far are:
> * created a wsdl file including the schema for my complextypes

It sounds like you created the wsdl from hand?  I went a different 
direction: I created a schema for each of my data types in an external 
schema, then attempted to import the schema by creating an <xsd:import> 
element using the writeSchema( ) method in the Serializer for that data 
type.

What I wanted to do originally was to extract the XML schema fragment 
used to create the JAXB object from the JAXB object itself, instead of 
having to reference a schema file.  That way I can build my JAXB objects 
and reference their <complexType> elements right from the object without 
having to go to an external XSD to retrieve them.  I was unable to do so.

In Suns reference implementation, each JAXB object has a private field 
"schemaFragment" which seems to contain the piece of schema used to 
create the object, but a. it is a private field b. I don't know how to 
get at it and c. it is encoded.  So presumably there is a decoder which 
is a. public and b. can get at the private field and c. can decode it 
but I've not found such a thing.

> * used axis wsdl2java tool to generate the skeleton, implementation and
> beans sources

I'm stuck on this step.  I get an error about a referenced, but 
undefined data type.  I'm not sure yet what the issue is but I'm going 
to do some heavy debugging this afternoon (hopefully).

> * created a custom JAXB serializer based on Castor serializer example

I initially tried to use JAXB and ran into some issues.  Do you have a 
code snippet I could take a look at?  I'm using Sun's JAXB 
implementation.  I can share as well (I have some code on a webpage).

> * modified wsdd to use the new JAXB serializer for each compleyType and
> element defined in the schema

Not there yet.

> * deployed stuff using adminclient

Yup, I'm doing that (over and over as I debug my service) :)

> * tested results using WSAD 5.1 Webservice explorer

I've never used this tool.  Is it freely available?

> Problems which i encountered:
> * A call to the webservice results in a Soap fault
> (java.lang.reflect.InvocationTargetException)
> * The wsdl file generated by Axis after deployment is invalid, it does not
> contain the complexType definitions which were defined in the original wsdl.
> How could this happen? When I leave out the type mappings in my deploy.wsdd
> and redeploy it produces a valid wsdl file...strange.

Interesting.  Do you get any wsdl at all when the typemapping is 
defined?  If so, can you compare the two wsdl documents and look for 
differences?

Elliot