my dog learned polymorphism*
The moose likes Web Services and the fly likes sending array of bytes through webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "sending array of bytes through webservice" Watch "sending array of bytes through webservice" New topic
Author

sending array of bytes through webservice

mansour polaris
Greenhorn

Joined: Jun 17, 2008
Posts: 3

Hi,

I need to send a byte array (i.e. byte[]) secret key from client to webservice to be used for encryption in both parties.

First I tried to build a method in webservice that accepts a byte [] and retrun byte [] as well but when I initiate the call from client I get this exception at client side:

javax.xml.rpc.JAXRPCException: Simple Type Mismatch
at com.sun.j2mews.xml.rpc.SOAPEncoder.encode(SOAPEncoder.java:81)
at com.sun.j2mews.xml.rpc.OperationImpl.invoke(OperationImpl.java:233)

I think because I edited the type of input/ouput parameters mannually in the stub to be Type.Byte becaue it was giving me UNKNOWN type.


Second I tried to convert byte array to string (i.e. new String(b,0,b.length) ) but when I initiate webservice call I get this exception at server side:

javax.xml.ws.soap.SOAPFaultException: Bad request
at com.sun.xml.ws.encoding.soap.SOAPDecoder.raiseFault(SOAPDecoder.java:674)
at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.raiseBadXMLFault(SOAPXMLDecoder.java:172)
at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java:87)



please help me how to transfer a byte array as parameter to webservice and get an output of byte array to the client?

is it allowed!!!
Sathees Tharmarajah
Greenhorn

Joined: Aug 09, 2009
Posts: 20
HI polaris,

"please help me how to transfer a byte array as parameter to webservice and get an output of byte array to the client?"

you can use the parameter type as javax.activation.DataHandler instead of byte[] ?

good luck

Sathees
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sending array of bytes through webservice