Vishnu,
Have you looked at the data on the wire, e.g. with tcpmon, TcpTunnelGui,
tcpdump, or netmon? That would indicate whether the serialization or
deserialization is at fault.
Scott Nichol
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 25, 2002 11:43 AM
Subject: Re: base 64 encoded xml string getting truncated
>
> Hi Scott,
>
> The byte array is already base 64 encoded and is a descendent
> ("binaryData") of the "itemElement" passed to the soap call.
> To make the things simpler, equiavalent client code is provided below:
>
> public static Document clientMethod(int userID, byte[] state) {
> System.out.println("byte[] length at client: " +
state.length);//about
> 100k
> String stateString = Base64.encode(state);
> System.out.println("encoded string length at client: " +
> stateString.length());//about 130k
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> DocumentBuilder db = dbf.newDocumentBuilder();
> Document doc = db.newDocument();
> Element itemElement = doc.createElement("item");
> itemElement.appendChild(doc.createTextNode(stateString));
> doc.appendChild(itemElement);
> URL rpcURL = null;
> try {
> rpcURL = new URL("http://localhost/soap/servlet/rpcrouter");
> } catch(MalformedURLException ex){
> ex.printStackTrace();
> }
> Call call = new Call();
> call.setTargetObjectURI("urn:ItemManagerPersistence");
> call.setMethodName("saveItem");
> call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
> Vector params = new Vector();
> params.addElement(new Parameter("userID", int.class, new
Integer(userID),
> Constants.NS_URI_SOAP_ENC));
> params.addElement(new Parameter("itemElement", Element.class,
> itemElement, Constants.NS_URI_LITERAL_XML));
> call.setParams(params);
> Response response = null;
> try {
> response = call.invoke(rpcURL, "");
> } catch(SOAPException ex) {
> ex.printStackTrace();
> }
> if(!response.generatedFault()) {
> Parameter returnValue = response.getReturnValue();
> Object value = returnValue.getValue();
> if(value != null) {
> Element element = (Element)value;
> try {
> doc = db.newDocument();
> Node importedNode = doc.importNode(element, true);
> doc.appendChild(importedNode);
> } catch(Exception ex){
> ex.printStackTrace();
> }
> } else {
> Fault fault = response.getFault();
> System.out.println("fault code: " + fault.getFaultCode() + " fault
> string: " + fault.getFaultString());
>
> }
> return doc;
> }
>
> Here is the method saveItem() code in provider class:
>
> public Element saveItem(int userID, Element itemElement) throws
> ItemManagerException {
> //debug code
> String stateText = itemElement.getFirstChild().getNodeValue();
> System.out.println("encoded string length in provider: " +
> stateText.length());//about 7k
> byte[] state = Base64.decode(stateText);
> System.out.println("byte[] length in provider: " +
state.length);//about
> 5k
> //save and return element
> return saveToDatabase(userID, itemElement);
> }
>
> You might wonder why we're not sending byte[] as a soap parameter,
that's
> because we need to send addtional information about the item(text
nodes)
> besides the byte[], the original "itemElement" contains many text
nodes
> besides the encoded byte[] string.
>
> Any insight why the encoded string is getting truncated is welcome,
>
> Thanks,
>
> Vishnu.
>
>
> |---------+----------------------------->
> | | Scott Nichol |
> | | <snicholnews@scott|
> | | nichol.com> |
> | | |
> | | 10/24/2002 06:04 |
> | | PM |
> | | Please respond to |
> | | soap-user |
> | | |
> |---------+----------------------------->
>
>-----------------------------------------------------------------------
----------------------------------------------------------------------|
> |
|
> | To: [EMAIL PROTECTED], [EMAIL PROTECTED]
|
> | cc: [EMAIL PROTECTED]
|
> | Subject: Re: base 64 encoded xml string getting truncated
|
>
>-----------------------------------------------------------------------
----------------------------------------------------------------------|
>
>
>
>
> I am not clear about what you are doing. The client code you show
> includes no byte array. Is the byte array on the server? I would
have
> to assume it is. Do you verify at the exit of your service method
that
> the string as contained in the DOM is the length you expect? Where in
> the provider do you check the string to see it is 5k? Are you
checking
> the string still in the DOM, or as serialized? If you are looking at
> the string while it is still in the DOM, I'm not sure what could have
> gone wrong.
>
> Scott Nichol
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, October 24, 2002 4:27 PM
> Subject: base 64 encoded xml string getting truncated
>
>
> > Hi,
> >
> > We have been successfully using apache soap over the past one year
> > for transferring java objects between web applications. We're using
> > soap 2.2 with websphere 3.5.4 servlet/ejb environment.
> >
> > We have a byte[] which is encoded to String using Base64 and the
> String is
> > placed as a child element in a Parent Element(which contains other
> > childeren).
> >
> > We notice that when the Element reaches the Provider Class the
encoded
> > string(one of the child elements)
> > is getting truncated(the original encoded string is about 100k and
the
> new
> > string is about 5k).
> >
> > Are there any limits on the size of byte[] that can be encoded and
> decoded
> > by Base64? Or are there any limits on
> > size of "Element" parameters to a soap call?
> >
> > Here is the client code:
> >
> > //"itemElement" is the whole xml which contains an element
> > "binaryData" which holds the encoded string
> > public static Document save(int userID, Element itemElement)
> throws
> > Exception {
> > // Set the SOAP RPC URL
> > URL rpcURL = null;
> > try{
> > rpcURL = new URL
> > ("http://localhost/soap/servlet/rpcrouter");
> > }catch(MalformedURLException ex){
> > throw new Exception("ItemManagerSOAPProxy::save -
"
> +
> > ex.getMessage());
> > }
> > // Build the SOAP call
> > Call call = new Call();
> > call.setTargetObjectURI("urn:ItemManagerPersistence");
> > call.setMethodName("saveItem");
> > call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
> > // Set the method parameters
> > Vector params = new Vector();
> > params.addElement(new Parameter("userID", int.class, new
> > Integer(userID), Constants.NS_URI_SOAP_ENC));
> > params.addElement(new Parameter("itemElement",
> Element.class,
> > itemElement, Constants.NS_URI_LITERAL_XML));
> > call.setParams(params);
> > // Invoke the call
> > Response response = null;
> > try{
> > response = call.invoke(rpcURL, "");
> > }catch(SOAPException ex){
> > throw new Exception("ItemManagerSOAPProxy::save -
> Caught
> > SOAPException (" + ex.getFaultCode() + "): " + ex.getMessage());
> > }
> > // Check the response
> > Document itemXMLDocument = null;
> > if(!response.generatedFault()){
> > Parameter returnValue = response.getReturnValue();
> > Object value = returnValue.getValue();
> > if(value != null) {
> > // Cast value to an Element
> > Element element = (Element)value;
> > try{
> > DocumentBuilderFactory dbf =
> > DocumentBuilderFactory.newInstance();
> > DocumentBuilder db =
> dbf.newDocumentBuilder
> > ();
> > itemXMLDocument = db.newDocument();
> > Node importedNode =
> > itemXMLDocument.importNode(element, true);
> >
> itemXMLDocument.appendChild(importedNode);
> > }
> > catch(Exception ex){
> > throw new Exception
> > ("ItemManagerSOAPProxy::save - " + ex.getMessage());
> > }
> > }
> > }else{
> > Fault fault = response.getFault();
> > throw new Exception("ItemManagerSOAPProxy::save -
> Fault
> > Code = " + fault.getFaultCode() + " and Fault String = " +
> > fault.getFaultString());
> > }
> > return itemXMLDocument;
> > }
> >
> > Here is the deployment descriptor: 'urn:ItemManagerPersistence'
> > ID urn:ItemManagerPersistence
> > Scope Application
> > Provider Type java
> > Provider Class
> com.intellequip.itemmanager.soap.ItemManagerSOAPProcessor
> > Use Static Class false
> > Methods saveItem, saveItemTemp, getItemByID, getItemTempByID,
> > deleteItemTemp
> >
> > Any ideas about what is happening?
> >
> > Thanks in advance,
> >
> > Vishnu.
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:soap-dev-unsubscribe@;xml.apache.org>
> > For additional commands, e-mail:
<mailto:soap-dev-help@;xml.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:soap-user-unsubscribe@;xml.apache.org>
> For additional commands, e-mail:
<mailto:soap-user-help@;xml.apache.org>
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:soap-user-unsubscribe@;xml.apache.org>
> For additional commands, e-mail:
<mailto:soap-user-help@;xml.apache.org>
>
>
--
To unsubscribe, e-mail: <mailto:soap-user-unsubscribe@;xml.apache.org>
For additional commands, e-mail: <mailto:soap-user-help@;xml.apache.org>