I don't see a definition for your default namespace. Is it set to the
xsd namespace? If not, then this:

        <xs:element name="Request" type="base64Binary" use="required"/>

should be this:

        <xs:element name="Request" type="xs:base64Binary" use="required"/>

Likewise for the "Result" element.

Anne

On 2/13/07, Christina Obry <[EMAIL PROTECTED]> wrote:




Hello,



I am trying to transfer binary data. I wrote a wsdl file with the following
part:



<wsdl:types>

  <xs:schema
targetNamespace="http://businessobjects.com/services/sample/byte1";>

       <xs:element name="SetIdRequest">

             <xs:complexType>

                <xs:sequence>

                    <xs:element name="ID" type="xs:string"/>


                </xs:sequence>

            </xs:complexType>

       </xs:element>

       <xs:element name="Request" type="base64Binary" use="required"/>

       <xs:element name="Response">

             <xs:complexType>

                <xs:sequence>

                  <xs:element name="ID" type="xs:string"/>

                  <xs:element name="Result" type="base64Binary"
use="required"/>

               </xs:sequence>

           </xs:complexType>

       </xs:element>

    </xs:schema>

</wsdl:types>



The Request and Result should be in binary data. When auto generating the
code, then these elements are generated as OMElement. I created the
OMElement as follows:



…

  OMFactory fac = OMAbstractFactory.getOMFactory();

  OMElement element = fac.createOMElement("data", omNS) ;



  DataHandler dataHandler = new DataHandler(data);



  OMText textData =  fac.createOMText(dataHandler,false);

  textData.setOptimize(true);

  element.addChild(textData);



  request.setRequest(element);

…



As far as I understand the binary data will now be contrained in the OMText
element and the request look like this:



<ns2:Request
xmlns:ns2="http://businessobjects.com/services/sample/byte1";>

      <data
xmlns="http://businessobjects.com/services/sample/client/byte1";>ICAgT...</data>

</ns2:Request>



I believe so far I have not done anything wrong. The problem occurs when
trying to parse the request. I get an error that when trying to get the text
element from the request stating: org.apache.axiom.om.OMException:
java.util.NoSuchElementException



However, when trying to debug the same code, I end up in an endless loop.
The auto generated code for parsing is as follows:



  public static Request
parse(javax.xml.stream.XMLStreamReader reader)

            throws java.lang.Exception {

            Request object = new Request();

            int event;



            try {

                while (!reader.isStartElement() && !reader.isEndElement())

                    reader.next();



                // Note all attributes that were handled. Used to differ
normal attributes

                // from anyAttributes.

                java.util.Vector handledAttributes = new java.util.Vector();



                while (!reader.isEndElement()) {

                    if (reader.isStartElement()) {

                        if (reader.isStartElement()) {

                            java.lang.String content =
reader.getElementText();

                               System.err.println(content);

                            org.apache.axiom.om.OMFactory fac =
org.apache.axiom.om.OMAbstractFactory.getOMFactory();

                            org.apache.axiom.om.OMNamespace omNs =
fac.createOMNamespace("http://businessobjects.com/services/sample/byte1";,

                                    "");

                            org.apache.axiom.om.OMElement _valueRequest =
fac.createOMElement("Request",

                                    omNs);

                            _valueRequest.addChild(fac.createOMText(

                                    _valueRequest,
content));

                            object.setRequest(_valueRequest);

                        } // End of if for expected property start element



                        else {

                            // A start element we are not expecting
indicates an invalid parameter was passed

                            throw new java.lang.RuntimeException(

                                "Unexpected subelement " +

                                reader.getLocalName());

                        }

                    } else {

                        reader.next();

                    }

                } // end of while loop

            } catch (javax.xml.stream.XMLStreamException e)
{

                throw new java.lang.Exception(e);

            }

            return object;

        }



Is there something wrong in my wsdl file, in the auto generated code, or in
the way I am using the code?



Thanks for the advice,

   Christina

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to