axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iksrazal <iksra...@gmail.com>
Subject Re: Base 64 decoding in web service
Date Wed, 30 Nov 2005 20:06:58 GMT
I do this quite a bit with Jboss 4.0.2 and their version of axis 1.2, 
converting a stateful sesion bean to a String to maintain state: 

 private String getId(EJBObject session) throws ServiceLocatorException {
                String id = null;
                try {
                        Handle handleSoapSession = session.getHandle();
                        ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
                        ObjectOutputStream stream = new 
ObjectOutputStream(baos);
                        stream.writeObject(handleSoapSession);
                        stream.flush();
                        stream.close();
                        id = new String(Base64.encode(baos.toByteArray()));
                } catch(Exception ex) {
                        throw new ServiceLocatorException(ex.getMessage());
                }
                return id;
        }

The id as a string is passed as a return value, mapped as a String in a wsdl 
complex object. So I know its possible. 

BTW, my base64 is from org/apache/commons/httpclient/Base64.java . 

HTH,
iksrazal

Em Quarta 30 Novembro 2005 18:07, o Gabsaga Tata escreveu:
> I am using the package org.apache.soap.encoding.soapenc.Base64 to decode
> base 64 encoded data. Below is my decode method in my webservice app.
> public byte[] base64DecodeData(String data)
>  {
>  byte[] bytes = null;
>
>  Base64 base64 = new Base64();
>  try
>  {
>  bytes = base64.decode(data);
>  }
>  catch (Exception ex)
>  {
>  System.out.println("Decoding exception: " + ex.toString());
>  }
>  return bytes;
>  }
>
> The string data parameter is the value extracted from element tag:
> <data encoding="base64-MIME">Base64EncodedDataHere</data>
> from a DOM Object where the value bas been base 64 encoded by the client
> application.
>
>
> I get the following error when running my base64DecodeData method. Any
> ideas what could be causing this? When my webservice is implemented as a
> regular java class, it works fine but when I convert it to a webservice, I
> get this error. Any help will be greatly appreciated.
>
>
> AxisFault
>  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
>  faultSubcode:
>  faultString: java.lang.reflect.InvocationTargetException
>  faultActor:
>  faultNode:
>  faultDetail:
>  {http://xml.apache.org/axis/}hostname:USAGXXTEST2286
> java.lang.reflect.InvocationTargetException
>  at
> org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:
>221) at
> org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:1
>28) at
> org.apache.axis.encoding.DeserializationContext.endElement(DeserializationC
>ontext.java:1087) at
> org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
> Source) at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispat
>cher.dispatch(Unknown Source) at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
> Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>  at javax.xml.parsers.SAXParser.parse(Unknown Source)
>  at
> org.apache.axis.encoding.DeserializationContext.parse(DeserializationContex
>t.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
>  at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
>  at
> org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandCh
>ecker.java:62) at
> org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
>  at org.apache.axis.client.Call.invokeEngine(Call.java:2765)
>  at org.apache.axis.client.Call.invoke(Call.java:2748)
>  at org.apache.axis.client.Call.invoke(Call.java:2424)
>  at org.apache.axis.client.Call.invoke(Call.java:2347)
>  at org.apache.axis.client.Call.invoke(Call.java:1804)
>  at
> com.simpaq.ws.CipherSoapBindingStub.processDocument(CipherSoapBindingStub.j
>ava:153) at CipherClient.run(CipherClient.java:78)
>  at CipherClient.main(CipherClient.java:105)

Mime
View raw message