XML String as input parm for WS?

Hi All.
This has probably been asked and answered a few times, but I can't seem to find a exact answer to my scenario:
I have a java method that accepts a string as a input parm. However, the string will contain a fully formatted XML string eg:
<?xml version=\"1.0\" standalone=\"yes\"?>
<CAMPUS_UPD>
<MSG_SEQ_NO>NATX_00000000000000200609141569398</MSG_SEQ_NO>
<EVENT_NAME>CAMPUS_UPD.UPD</EVENT_NAME>
<STATUSCODE>000</STATUSCODE>
<CAMPUS_KODE>01</CAMPUS_KODE>
<CAMPUS_NAME>STELLENBOSCH</CAMPUS_NAME>
</CAMPUS_UPD>
I'm basically going to put this XML string directly onto a InterConnect AQ Table for consumption by Interconnect.
Now naturally I get a VERY strange set of errors when I actually try to call the WS with this XML String.
<HTML><HEAD><TITLE>Web Service</TITLE></HEAD><BODY><H1>Bad Request</H1><PRE>Error parsing envelope: (4, 30) PI with the name 'xml' can occur only in the beginning of the document.</PRE></BODY></HTML>
If I remove the first line of the XML string, the error message changes to:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://sun.oic.ws/types/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: KAMPUS_UPD</faultstring></env:Fault></env:Body></env:Envelope>
Any Ideas/suggestions/wild speculations/URL's etc.
Kind Regards
Elmar Matthee
University of Stellenbosch
South Africa

Hi Eric/all.
Just thought I'd give a follow up on my progress.
Got the web services working and finally able to test via Jdev. Seems the problem was with the proxy server settings of jdeveloper itself. I had localhost specified as an ip NOT to use a proxy server for, but when the test code got generated it used the actual ip of my machine (where the application server is also running) to access the web service, and thats where it got stuck.
I actually sent along the embedded xml string in a string parameter directly to the the web service, and it worked like a charm (as opposed to testing it via the application server administration web page where I had to translate the < and > characters. So quite chuffed with that.
Today I'm researching a) What happens when you have a complex data type (i.e. a java class containing 3 fields like username/fullname/age) from a web service. When I test it via the application server web page, I get the actual fields with their names and values in an xml type format back, but when I test it via java, i get a reference to the object. Now I could cast the result back into the class definition that I used when creating the web service, but what if I don't know what that is (i.e. someone else somewhere wrote the WS, and I have no idea about implementation)?
b) related to a) is how to convert the complex data type return value into an XML string before sending the reply (or maybe even a pure String containing the XML data). I.e. instead of sending a Person class, I send back an XML data type containing the relevant data with tags and all. I'm a bit worried about this, because it looks as if the data is alreaddy actually coming back in an XML format, its just that the java test program doesn't see it that way, and I'm loath add the extra overhead if it isn't needed.
c) related to both a) and b). How the @$#@ does one actually use/call a web service in a simple .jsp page? Seemingly a simple question, but thus far, the answer eludes me. :)
Any thoughts/comments/ideas/wild speculations/urls welcome.
Kind Regards.
Elmar

Similar Messages

  • Is it possible to pass array of strings as input parameters for stored proc

    Dear All,
    I wrote a Stored Procedure for my crystal report. now i got a modification.
    one of the parameters 'profit_center' should be modified so that it is capable to take multiple values.
    now when i run report crystal report collects more than one values for parameter profit_center and sends it as input parameter to stored procedure all at a time.
    the only way to handle this situation is the input parameter for stored procedure 'profit_center' should be able to take array of values and i have a filter gl.anal_to = '{?profit_center}'. this filter should also be modified to be good for array of values.
    Please Help.

    Or you can use sys.ODCIVarchar2List
    SQL> create or replace procedure print_name( In_Array sys.ODCIVarchar2List)
        is
        begin
                for c in ( select * from table(In_Array) )
                loop
                        dbms_output.put_line(c.column_value);
                end loop ;
        end ;
    Procedure created.
    SQL>
    SQL> exec print_name(sys.ODCIVarchar2List('ALLEN','RICHARD','KING')) ;
    ALLEN
    RICHARD
    KING
    PL/SQL procedure successfully completed.SS

  • XML message as input for webservice gives deserialization error

    Hi,
    jDeveloper 10.1.3
    BPEL PM 10.1.2.0.2
    Carrental example
    Problem:
    For the Business Rule Engine I did the Carrental XML example. Based on the java application that connects to the BR engine, I created a webservice in jDeveloper and deployed it to my localhost AS 10.1.3. The webservice has a testRule method that accepts a String buf as input. For now, the only thing the webservice does is return a 'do nothing' string. This works fine:
    When deployed the testpage generates the following SOAP message:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://carrental/types/">
    <ns1:testRuleElement>
    <ns1:buf>my xml message</ns1:buf>
    </ns1:testRuleElement>
    </soap:Body>
    </soap:Envelope>
    The SOAP response is:
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://carrental/types/"><env:Body><ns0:testRuleResponseElement><ns0:result>do nothing...</ns0:result></ns0:testRuleResponseElement></env:Body></env:Envelope>
    In BPEL Designer I create a new asynchronous process ValidateBR, with a partnerlink for the webservice, based on the following WSDL file:
    <definitions
    name="Rent"
    targetNamespace="http://carrental/"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://carrental/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:tns0="http://carrental/types/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    >
    <types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://carrental/types/"
    elementFormDefault="qualified" xmlns:tns="http://carrental/types/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/">
    <complexType name="testRule">
    <sequence>
    <element name="buf" type="string" nillable="true"/>
    </sequence>
    </complexType>
    <complexType name="testRuleResponse">
    <sequence>
    <element name="result" type="string" nillable="true"/>
    </sequence>
    </complexType>
    <complexType name="version">
    <sequence/>
    </complexType>
    <complexType name="versionResponse">
    <sequence>
    <element name="result" type="string" nillable="true"/>
    </sequence>
    </complexType>
    <element name="testRuleElement" type="tns:testRule"/>
    <element name="testRuleResponseElement" type="tns:testRuleResponse"/>
    <element name="versionElement" type="tns:version"/>
    <element name="versionResponseElement" type="tns:versionResponse"/>
    </schema>
    </types>
    <message name="Rent_testRule">
    <part name="parameters" element="tns0:testRuleElement"/>
    </message>
    <message name="Rent_testRuleResponse">
    <part name="parameters" element="tns0:testRuleResponseElement"/>
    </message>
    <message name="Rent_version">
    <part name="parameters" element="tns0:versionElement"/>
    </message>
    <message name="Rent_versionResponse">
    <part name="parameters" element="tns0:versionResponseElement"/>
    </message>
    <portType name="Rent">
    <operation name="testRule">
    <input message="tns:Rent_testRule"/>
    <output message="tns:Rent_testRuleResponse"/>
    </operation>
    <operation name="version">
    <input message="tns:Rent_version"/>
    <output message="tns:Rent_versionResponse"/>
    </operation>
    </portType>
    <binding name="RentSoapHttp" type="tns:Rent">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="testRule">
    <soap:operation soapAction="http://carrental//testRule"/>
    <input>
    <soap:body use="literal" parts="parameters"/>
    </input>
    <output>
    <soap:body use="literal" parts="parameters"/>
    </output>
    </operation>
    <operation name="version">
    <soap:operation soapAction="http://carrental//version"/>
    <input>
    <soap:body use="literal" parts="parameters"/>
    </input>
    <output>
    <soap:body use="literal" parts="parameters"/>
    </output>
    </operation>
    </binding>
    <service name="Rent">
    <port name="RentSoapHttpPort" binding="tns:RentSoapHttp">
    <soap:address location="http://localhost:7780/Rules-rent-context-root/RentSoapHttpPort"/>
    </port>
    </service>
    </definitions>
    I defined the process variable inputVariable to be defined based on the carrental.xsd schema. I assign the inputVariable to the 'buf' parameter of the webservice as shown below in the ValidateBR.bpel
    <!--
    // Oracle JDeveloper BPEL Designer
    // Created: Mon Mar 27 16:02:22 CEST 2006
    // Author: haanrw
    // Purpose: Asynchronous BPEL Process
    -->
    <process name="ValidateBR" targetNamespace="http://xmlns.oracle.com/ValidateBR" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:ns1="http://rules.oracle.com/carrental" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns3="http://carrental/types/" xmlns:ns2="http://carrental/" xmlns:client="http://xmlns.oracle.com/ValidateBR" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"><!-- ================================================================= --><!-- PARTNERLINKS --><!-- List of services participating in this BPEL process --><!-- ================================================================= -->
    <partnerLinks><!--
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    <partnerLink name="client" partnerLinkType="client:ValidateBR" myRole="ValidateBRProvider" partnerRole="ValidateBRRequester"/>
    <partnerLink name="CheckBR" partnerRole="Rent_Role" partnerLinkType="ns2:Rent_PL"/>
    </partnerLinks><!-- ================================================================= --><!-- VARIABLES --><!-- List of messages and XML documents used within this BPEL process --><!-- ================================================================= -->
    <variables><!-- Reference to the message passed as input during initiation -->
    <variable name="inputVariable" messageType="client:ValidateBRRequestMessage"/><!-- Reference to the message that will be sent back to the
    requester during callback
    -->
    <variable name="outputVariable" messageType="client:ValidateBRResponseMessage"/>
    <variable name="InvokeValidateBR_testRule_InputVariable" messageType="ns2:Rent_testRule"/>
    <variable name="InvokeValidateBR_testRule_OutputVariable" messageType="ns2:Rent_testRuleResponse"/>
    </variables><!-- ================================================================= --><!-- ORCHESTRATION LOGIC --><!-- Set of activities coordinating the flow of messages across the --><!-- services integrated within this business process --><!-- ================================================================= -->
    <sequence name="main"><!-- Receive input from requestor.
    Note: This maps to operation defined in ValidateBR.wsdl
    -->
    <receive name="receiveInput" partnerLink="client" portType="client:ValidateBR" operation="initiate" variable="inputVariable" createInstance="yes"/><!-- Asynchronous callback to the requester.
    Note: the callback location and correlation id is transparently handled
    using WS-addressing.
    -->
    <assign name="Assign_1">
    <copy>
    <from variable="inputVariable" part="payload" query="/ns1:repository"/>
    <to variable="InvokeValidateBR_testRule_InputVariable" part="parameters" query="/ns3:testRuleElement/ns3:buf"/>
    </copy>
    </assign>
    <invoke name="InvokeValidateBR" partnerLink="CheckBR" portType="ns2:Rent" operation="testRule" inputVariable="InvokeValidateBR_testRule_InputVariable" outputVariable="InvokeValidateBR_testRule_OutputVariable"/>
    <invoke name="callbackClient" partnerLink="client" portType="client:ValidateBRCallback" operation="onResult" inputVariable="outputVariable"/>
    </sequence>
    </process>
    When I deploy the process and initiate a testinstance from the BPEL console, the assign looks as follows:
    <InvokeValidateBR_testRule_InputVariable>
    <part name="parameters" >
    <testRuleElement>
    <buf>
    <driver>
    <driver-license-number>15-PS-FZ</driver-license-number>
    <name>Rob de Haan</name>
    <age>39</age>
    <vehicle-type>Saab</vehicle-type>
    <license-type>B</license-type>
    <pre-convictions>0</pre-convictions>
    <pre-accidents>0</pre-accidents>
    <able-to-drive>true</able-to-drive>
    </driver>
    </buf>
    </testRuleElement>
    </part>
    </InvokeValidateBR_testRule_InputVariable>
    The InvokeValidateBR shows the following error:
    <remoteFault>
    <part name="code" >
    <code>Client</code>
    </part>
    <part name="summary" >
    <summary>when invoking endpointAddress 'http://localhost:7780/Rules-rent-context-root/RentSoapHttpPort', caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: {http://rules.oracle.com/carrental}driver</summary>
    </part>
    <part name="detail" >
    <detail>AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client faultSubcode: faultString: caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: {http://rules.oracle.com/carrental}driver faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: {http://rules.oracle.com/carrental}driver at org.collaxa.thirdparty.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221) at org.collaxa.thirdparty.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128) at org.collaxa.thirdparty.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1083) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.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.XML11Configuration.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.collaxa.thirdparty.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:226) at org.collaxa.thirdparty.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645) at org.collaxa.thirdparty.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.collaxa.thirdparty.apache.axis.client.Call.invokeEngine(Call.java:2754) at org.collaxa.thirdparty.apache.axis.client.Call.invoke(Call.java:2715) at org.collaxa.thirdparty.apache.axis.client.Call.invoke(Call.java:1737) at com.collaxa.cube.ws.wsif.providers.axis.WSIFOperation_ApacheAxis.invokeAXISMessaging(WSIFOperation_ApacheAxis.java:2113) at com.collaxa.cube.ws.wsif.providers.axis.WSIFOperation_ApacheAxis.invokeRequestResponseOperation(WSIFOperation_ApacheAxis.java:1611) at com.collaxa.cube.ws.wsif.providers.axis.WSIFOperation_ApacheAxis.executeRequestResponseOperation(WSIFOperation_ApacheAxis.java:1083) at com.collaxa.cube.ws.WSIFInvocationHandler.invoke(WSIFInvocationHandler.java:452) at com.collaxa.cube.ws.WSInvocationManager.invoke2(WSInvocationManager.java:327) at com.collaxa.cube.ws.WSInvocationManager.invoke(WSInvocationManager.java:189) at com.collaxa.cube.engine.ext.wmp.BPELInvokeWMP.__invoke(BPELInvokeWMP.java:601) at com.collaxa.cube.engine.ext.wmp.BPELInvokeWMP.__executeStatements(BPELInvokeWMP.java:317) at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:188) at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3408) at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1836) at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75) at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:166) at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:252) at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5438) at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:1217) at com.collaxa.cube.engine.delivery.DeliveryService.handleInvoke(DeliveryService.java:511) at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleInvoke(CubeDeliveryBean.java:335) at ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.handleInvoke(ICubeDeliveryLocalBean_StatelessSessionBeanWrapper16.java:1796) at com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessageHandler.handle(InvokeInstanceMessageHandler.java:37) at com.collaxa.cube.engine.dispatch.DispatchHelper.handleMessage(DispatchHelper.java:125) at com.collaxa.cube.engine.dispatch.BaseScheduledWorker.process(BaseScheduledWorker.java:70) at com.collaxa.cube.engine.ejb.impl.WorkerBean.onMessage(WorkerBean.java:86) at com.evermind.server.ejb.MessageDrivenBeanInvocation.run(MessageDrivenBeanInvocation.java:123) at com.evermind.server.ejb.MessageDrivenHome.onMessage(MessageDrivenHome.java:755) at com.evermind.server.ejb.MessageDrivenHome.run(MessageDrivenHome.java:928) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186) at java.lang.Thread.run(Thread.java:534) {http://xml.apache.org/axis/}hostname:NL-GRH-L120981 </detail>
    </part>
    </remoteFault>
    FYI: the webservice only contains a return "do nothing"
    Question:
    What is the proper way to assign an XML message to the web service?
    Any help would be appreciated.
    Rob
    Message was edited by:
    [email protected]

    Hi,
    Reading only is not possible..
    I will be still more clear in my question this time..
    I have deployed my bpel. My receiveInputVariable is of type xsd:string.
    So when i run the bpel in my console, i will be asked to give input as string data.
    So when i go to the XMLView, it will be like this.
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
         <soap:Body xmlns:ns1="http://xmlns.oracle.com/Sabari_POC_Appln/DOM_Parser/ConvertToBLOB">
              <ns1:process>
                   <ns1:input></ns1:input>
    </ns1:process>
    </soap:Body>
    </soap:Envelope>
    Now, i am going to give my input like this. --- which leads to error.
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
         <soap:Body xmlns:ns1="http://xmlns.oracle.com/Sabari_POC_Appln/DOM_Parser/ConvertToBLOB">
              <ns1:process>
                   <ns1:input>
    *<?xml version="1.0" encoding="UTF-8"?>*
    *<projects>*
    *<project id = "BP001">*
    *<name>Banking Project</name>*
    *<start-date>Jan 10 1999</start-date>*
    *<end-date>Jan 10 2003</end-date>*
    *</project>*
    *<project id = "TP001">*
    *<name>Telecommunication Project</name>*
    *<start-date>March 20 1999</start-date>*
    *<end-date>July 30 2004</end-date>*
    *</project>*
    *<project id = "PP001">*
    *<name>Portal Project</name>*
    *<start-date>Dec 10 1998</start-date>*
    *<end-date>March 10 2006</end-date>*
    *</project>*
    *</projects>*
    </ns1:input>
    </ns1:process>
    </soap:Body>
    </soap:Envelope>
    This xml is not accepted as string input.. so kindly suggest me some other solution.
    I also tried.. like.. making my receiveInputVariable of type xsd:anyType, it also dint help. same error occurred.
    Thanks,
    Sabarisri. N
    Edited by: Sabarisri N on Jul 20, 2011 1:03 PM

  • How to create XML string for an object matching the result of a marshal?

    I'm trying to create a XML string representation of an object which exactly matches the XML which results from marshalling the object into a request. I'm almost there except that the XML string I come up with is missing the attribute "standalone=\"yes\"" in the topmost xml element, and this attribute is present in the marshalled XML. I'm using the XML string to create a payload signature which must match exactly with the XML payload of the request, so the two XML representations of the object really do need to be identical.
    Here's what I'm doing to create the XML from the object:
       private String myObjectToXmlString (final MyObject myObject)
           throws Exception {
                 try {
               DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
               Document document = documentBuilder.newDocument();
               myObjectMarshaller.marshal(myObject, document);
               Source source = new DOMSource(document);
               StringWriter stringWriter = new StringWriter();
               Result result = new StreamResult(stringWriter);
               TransformerFactory factory = TransformerFactory.newInstance();
               Transformer transformer = factory.newTransformer();
               transformer.transform(source, result);
               return stringWriter.getBuffer().toString();
           } catch (Exception ex) {
               throw new Exception("Unable to convert a MyObject object to an XML String -- " + ex.toString(), ex);
       }The XML which is produced looks like this:
    <?xml version=\"1.0\" encoding=\"UTF-8\"?>
    <ns2:myObject xmlns:ns2=\"http://sunconnection.sun.com/xml\">
       <myObjectId>0</myObjectId>
       <objectType>1</objectType>
       <description>Test Object</description>
    </ns2:myObject>The payload object is marshalled to the request like so:
        // marshall the MyObject to the output stream
       OutputStream outputStream = myHttpUrlConnection.getOutputStream();
       myObjectMarshaller.marshal(myObject, outputStream);
       outputStream.flush();
       outputStream.close();When I view the XML payload of the request it looks like this:
    <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
    <ns2:myObject xmlns:ns2=\"http://sunconnection.sun.com/xml\">
       <myObjectId>0</myObjectId>
       <objectType>1</objectType>
       <description>Test Object</description>
    </ns2:myObject>As you can see the two XML representations of the object are identical except for the standalone attribute in the xml element.
    It'd be a hack to make the assumption that the standalone attribute will always be there in the marshalled object and to just hard code it into the XML string returned by my object to XML method. Since I'm using the same Marshaller to create the XML string as I am to perform the marshalling to the request I assume that there's some way to make it give the same XML in both cases, and that I'm doing something wrong in my method which converts the object to an XML string. If anyone can see where I'm going wrong in that method (myObjectToXmlString() above), or can suggest a better way of doing this, then I'll certainly appreciate the insight.
    --James                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    It turns out that I was taking the wrong approach in my object to XML string method. A cleaner/better way to do it, which gives the correct result, is this:
        private String myObjectToXmlString (final MyObject myObject)
            throws Exception {
            try {
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                myObjectMarshaller.marshal(myObject, stream);
                return stream.toString();
            } catch (Exception ex) {
                throw new Exception("Unable to convert a MyObject object to an XML String -- " + ex.toString(), ex);
        }--James                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Flex input type for c# string array: string[]

    Quick question, what would the input type for Flex be if the data type on the asp.net c# web service was a string array, string[], it seems to autodetect it as an ArrayCollection but that isnt right, so I would assume array, but i would still like to confirm this.
    thanks
    shaine

    it was actually arraycollection :\
    the actual answer is:
    var _compEmp:ArrayCollection = new ArrayCollection(new Array("Shaine Fisher"));
    thanks

  • Xml string in Java - forbidden characters for data?

    Hi there,
    In my java class I am building a xml string and saving it as a xml file in the hard drive. Later when I open the file in the XML editor it gets errors "forbidden characters". I think the problem is that in the data there can be characters as & or <> and of course that would disturbe the xml structure. Is there any smart method in Java which convert all the forbidden characters for xml data?... many thanks for any hints.

    emailkia wrote:
    In my java class I am building a xml string and saving it as a xml file in the hard drive. I am guessing that you are building a string into which you are putting what you think is xml.
    And it isn't.
    So the real solution is to build it correctly in the first place.
    Is there any smart method in Java which convert all the forbidden characters for xml data?There are also libraries that will allow you to build xml which handle those sorts of issues for you.

  • URLEncoder and URLDecoder for posting XML Strings

    Hi All
    I need to post an XML string to another website using POST.
    I have some java code that generates the XML string and sets the request object with this parameter. In my JSP I need to assign this to a hidden form element so that when a user clicks on "Submit", the destination site can extract the xml string.
    The problem i am facing is that while setting the hidden form element
    e.g. <input type=hidden name=xmlstr value= //Set it by reading the parameter from the request object.
    only the initial part of the string is picked up i.e. only upto the first double quotes " i.e. upto <?xml version=
    I am thinking of using URLEncoding to encode the xml while posting and URLDecoding to decode this xml.
    Is there a better way of doing this ?
    Thanks
    Bits

    I think that is the 'correct' thing to do. parameter values must be URLEncoded whether being posted or not.

  • Input form for creating an xml document

    are there any utilities which will help me to create an input form for an xml file. The requirement is to come up with a form which will help me input data which can be saved as an xml file.

    Thanks Camalot,
    I was just thinking of selecting images from the finder but if this could be integrated into Aperture's export dialog that would be even better.
    this is the xml:
    <?xml version="1.0" encoding="utf-8"?>
    <gallery thumbwidth="220" thumbheight="138" columns="3" gap="4">
    <item>
    <ID>1</ID>
    <title><![CDATA[Title 1]]></title>
    <desc><![CDATA[This is description 1. <font color="#0099CC">This is a colourful text. </font> This is a <a href="http://www.flashden.net/user/iceonflames">link</a>. <i>This is italic text.</i> <b>This is bold text.</b> <b><i>This is bold italic text.</i></b> This text is styled by a CSS document.<br/><br/>]]></desc>
    <thumb>images/thumbs/7.jpg</thumb>
    <image>images/big/7.jpg</image>
    </item>
    <item>
    <ID>2</ID>
    <thumb>images/thumbs/8.jpg</thumb>
    <image>images/big/8.jpg</image>
    </item>
    <item>
    <ID>3</ID>
    <title><![CDATA[Title 3]]></title>
    <desc><![CDATA[This is description 3. <font color="#0099CC">This is a colourful text. </font> This is a <a href="http://www.flashden.net/user/iceonflames">link</a>. <i>This is italic text.</i> <b>This is bold text.</b> <b><i>This is bold italic text.</i></b> This text is styled by a CSS document.<br/><br/>]]></desc>
    <thumb>images/thumbs/9.jpg</thumb>
    <image>images/big/9.jpg</image>
    </item>
    </gallery>

  • Performance problem submitting big XML string parameter to the web service

    We deployed a web service on the OC4J via oracle.j2ee.ws.StatelessJavaRpcWebService . This web service takes one string as a parameter. The string contains XML. Evrything works great UNLESS input XML string reaches 5Mb in size. When it happens OC4J does something with it for about 10 minutes (yes, minutes) before it calls the web service method. At this time java.exe consumes 100% of CPU.
    WE tried to increase JVM heap size, stack size, etc, - no effect.
    Please, help!
    Thank you in advance,
    Vlad.

    Hi Sheldon,
    What i feel is that it's not been handled in your webservice if the parameter is null or "" <blank> space
    i just you to take care in webservice that if the parameter is null or "" pass the parameter null to the stored proc
    Regards
    Pavan

  • How to get an XML string from a Java Bean without wrting to a file first ?

    I know we can save a Java Bean to an XML file with XMLEncoder and then read it back with XMLDecoder.
    But how can I get an XML string of a Java Bean without writing to a file first ?
    For instance :
    My_Class A_Class = new My_Class("a",1,2,"Z", ...);
    String XML_String_Of_The_Class = an XML representation of A_Class ?
    Of course I can save it to a file with XMLEncoder, and read it in using XMLDecoder, then delete the file, I wonder if it is possible to skip all that and get the XML string directly ?
    Frank

    I think so too, but I am trying to send the object to a servlet as shown below, since I don't know how to send an object to a servlet, I can only turn it into a string and reconstruct it back to an object on the server side after receiving it :
    import java.io.*;
    import java.net.*;
    import java.util.*;
    class Servlet_Message        // Send a message to an HTTP servlet. The protocol is a GET or POST request with a URLEncoded string holding the arguments sent as name=value pairs.
      public static int GET=0;
      public static int POST=1;
      private URL servlet;
      // the URL of the servlet to send messages to
      public Servlet_Message(URL servlet) { this.servlet=servlet; }
      public String sendMessage(Properties args) throws IOException { return sendMessage(args,POST); }
      // Send the request. Return the input stream with the response if the request succeeds.
      // @param args the arguments to send to the servlet
      // @param method GET or POST
      // @exception IOException if error sending request
      // @return the response from the servlet to this message
      public String sendMessage(Properties args,int method) throws IOException
        String Input_Line;
        StringBuffer Result_Buf=new StringBuffer();
        // Set this up any way you want -- POST can be used for all calls, but request headers
        // cannot be set in JDK 1.0.2 so the query string still must be used to pass arguments.
        if (method==GET)
          URL url=new URL(servlet.toExternalForm()+"?"+toEncodedString(args));
          BufferedReader in=new BufferedReader(new InputStreamReader(url.openStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
        else     
          URLConnection conn=servlet.openConnection();
          conn.setDoInput(true);
          conn.setDoOutput(true);           
          conn.setUseCaches(false);
          // Work around a Netscape bug
          conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
          // POST the request data (html form encoded)
          DataOutputStream out=new DataOutputStream(conn.getOutputStream());
          if (args!=null && args.size()>0)
            out.writeBytes(toEncodedString(args));
    //        System.out.println("ServletMessage args: "+args);
    //        System.out.println("ServletMessage toEncString args: "+toEncodedString(args));     
          BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream()));
          while ((Input_Line=in.readLine()) != null) Result_Buf.append(Input_Line+"\n");
          out.flush();
          out.close(); // ESSENTIAL for this to work!          
        return Result_Buf.toString();               // Read the POST response data   
      // Encode the arguments in the property set as a URL-encoded string. Multiple name=value pairs are separated by ampersands.
      // @return the URLEncoded string with name=value pairs
      public String toEncodedString(Properties args)
        StringBuffer sb=new StringBuffer();
        if (args!=null)
          String sep="";
          Enumeration names=args.propertyNames();
          while (names.hasMoreElements())
            String name=(String)names.nextElement();
            try { sb.append(sep+URLEncoder.encode(name,"UTF-8")+"="+URLEncoder.encode(args.getProperty(name),"UTF-8")); }
    //        try { sb.append(sep+URLEncoder.encode(name,"UTF-16")+"="+URLEncoder.encode(args.getProperty(name),"UTF-16")); }
            catch (UnsupportedEncodingException e) { System.out.println(e); }
            sep="&";
        return sb.toString();
    }As shown above the servlet need to encode a string.
    Now my question becomes :
    <1> Is it possible to send an object to a servlet, if so how ? And at the receiving end how to get it back to an object ?
    <2> If it can't be done, how can I be sure to encode the string in the right format to send it over to the servlet ?
    Frank

  • JDOM: Parsing XML String, getting error

    Hello,
    I am new to this forum, so please forgive me
    if this has already been asked before. I want to
    parse an XML string. I know the JDOM parser works
    great with a file, but apparently I have been
    unsuccessful parsing an XML String. Below is how I
    initialize the parser:
    import java.io.*; //Import proper packages
    import org.jdom.*;
    import org.jdom.input.*;
    import org.jdom.output.*;
    import java.util.*;
    import java.lang.*;
    public class XMLParser{
    private Document doc = null;
    public XMLParser(String xml){
    doc = readDocument(xml);
    private Document readDocument(String xml) {
    try {
    SAXBuilder builder = new SAXBuilder();
    org.jdom.Document result = builder.build(new
    StringReader(xml));
    return result;
    } catch(JDOMException e) {
    e.printStackTrace();
    } catch(NullPointerException e) {
    e.printStackTrace();
    return null;
    } //readDocument
    The following is the error I receive:
    JDOM/xmlparser.java [81:1] cannot resolve symbol
    symbol : method build (java.io.StringReader)
    location: class org.jdom.input.SAXBuilder
    org.jdom.Document result = builder.build(new
    StringReader(filename));
    --> Arrow pointing to builder.build
    Please if someone can help me out. If JDOM does not
    have this feature, then can someone please recommend a
    parser that can parse an XML String.

    Thank you for your help, although it seems like it was JDom 9 beta. When I tried with JDOM 8 beta, everything worked fine even with the StringReader. So if anyone is having similar problems with JDom 9 then try with JDom 8.

  • Parsing an xml string into id-value pair format

    Hi,
    I am new in oracle BPEL.
    My requirement is that I need to parse an xml string containing tag name and coressponding value into an 'id -value' pair.
    For example-
    The input xml format is -
    <employee>
    <empid>12345</empid>
    <name>xyz</name>
    <city>London</city>
    </employee>
    The required xml format is-
    <employee>
    <item id="empid" value="12345"/>
    <item id="name" value="xyz"/>
    <item id="city" value="London"/>
    </employee>
    Please let me know if there is a work-around for this.
    Thanks

    Something like this (have not tested):
    <xsl:for-each select="//employee">
    <employee>
    <xsl:for-each select="./*">
    <item>
    <xsl:attribute name="id">
    <xsl:value-of select="name()"/>
    </xsl:attribute>
    <xsl:attribute name="value">
    <xsl:value-of select="text()"/>
    </xsl:attribute>
    </item>
    </xsl:for-each>
    </employee>
    </xsl:for-each>

  • Parsing an XML string

    How would I get the Oracle XML Parser to parse an XML string?
    The example ("DOMSample") only demonstrates how to parse an XML
    file -- I would like to do something of the form...
    parser.parse("<test>testing</test>");
    On a related note, whilst the PL/SQL utilities are helpful, I
    would like to see more in the way of documentation and examples
    for the Parser itself, showing more examples of DOM API calls and
    perhaps a complete worked example (including a DTD).
    Keep up the good work!
    Many thanks,
    Ian Brettell,
    Indus International.
    null

    Ian Brettell (guest) wrote:
    : How would I get the Oracle XML Parser to parse an XML string?
    : The example ("DOMSample") only demonstrates how to parse an XML
    : file -- I would like to do something of the form...
    : parser.parse("<test>testing</test>");
    With the latest version, 1.0.0.1, now available, you can use the
    InputStream and InputSource methods. Please see the doc for
    details.
    : On a related note, whilst the PL/SQL utilities are helpful, I
    : would like to see more in the way of documentation and examples
    : for the Parser itself, showing more examples of DOM API calls
    and
    : perhaps a complete worked example (including a DTD).
    : Keep up the good work!
    : Many thanks,
    : Ian Brettell,
    : Indus International.
    Thanks for the input. I will pass it onto the documentation team.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • How to parse xml string

    Hi! I'm having problems parsing an xml string. I've done DOM and SAX parsing before. But both of them either parse a file or data from an input source. I don't think they handle strings. I also don't want to write the string into a file just so I can use DOM or SAX.
    I'm looking for something where I could simply do:
    Document doc = documentBuilder.parse( myXMLString );
    So the heirarchy is automatically established for me. Then I could just do
    Element elem = doc.getElement();
    String name = elem.getTagName();
    These aren't the only methods I would want to use. Again, my main problem is how to parse xml if it is stored in a string, not a file, nor comming from a stream.
    thanks!

    But both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));

  • Printint XML string using  XSLT mapping

    Hi,
    I'm trying to build a outgoing SOAP message with in XI, my backedn legacy application expect the soap message to be in certain format. It expect the xml request passed in the body of the message as whole xml string. I need to pring the xml something like this, I would appreciate if anyone had implemented something like this before. if you look at the below message I'm enclosing the whole xml string in the data element.
    <data xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?> <crm:schedule_call_request session_id="mid://07060623130210031519@elnk_crm.com" target_system_id="csi_ivr" xmlns:crm="https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_crm.xsd" xmlns:xcommon="https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_common.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_crm.xsd https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_crm.xsd https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_common.xsd https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_common.xsd"> <crm:call_parameter global_rules_version_id="" manual_request="true" originating_skillset="TS (DU/BB)|ADSL RETAIL" parameter_version_id="1" transfer_skillset="TSBBDSL...WinELNK"> <crm:call_id>10031519</crm:call_id> <crm:department_name>TS</crm:department_name> <crm:object_type>CASE</crm:object_type> <crm:object_id>73079085</crm:object_id> <crm:call_time>2007-06-07T12:30:01.000-08:00</crm:call_time> <crm:customer_phone_number>6263452656</crm:customer_phone_number> <crm:override_attempts>false</crm:override_attempts> <crm:retry_count>3</crm:retry_count> <crm:call_trigger>3000</crm:call_trigger> <crm:call_time_padding>10</crm:call_time_padding> <crm:override_local_customer_call_hours>false</crm:override_local_customer_call_hours> </crm:call_parameter> </crm:schedule_call_request></data>

    Hi
    thanks for responding. here is the input SOAP message that I was building in the XLT mapping. I was stuck at putting the xml in the data element.
    soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    - <soapenv:Header>
    - <wsa:EndpointReference soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
      <wsa:Address xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">https://xmlc-qe.corp.earthlink.net/ws_xmlc/s_router</wsa:Address>
      <wsa:ServiceName wsa:PortName="XMLCollectivePort" xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">wsa:ServiceName</wsa:ServiceName>
      </wsa:EndpointReference>
      <wsa:To soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">https://xmlc-qe.corp.earthlink.net/ws_xmlc/queues/csi_queue</wsa:To>
      <wsa:Action soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">https://xmlc-qe.corp.earthlink.net/ws_xmlc/action//messaging/put_single</wsa:Action>
      <wsa:MessageID soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">07060623130210031519</wsa:MessageID>
    - <wsse:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
    - <wsse:UsernameToken>
      <wsse:Username xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">elnk_crm</wsse:Username>
      <wsse:Password wsse:Type="wsse:PasswordDigest" xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">20UioFa77hI6MLhlc+KPDF95Hx0=</wsse:Password>
      <wsse:Nonce xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">VlX1Jpoq+vkQCQ8af2SaCDP1u9c=</wsse:Nonce>
      <wsu:Created xsi:type="soapenc:string" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2007-06-06T23:13:12Z</wsu:Created>
      </wsse:UsernameToken>
      </wsse:Security>
      </soapenv:Header>
    - <soapenv:Body>
    - <ns1:SubmitRequest soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="SubmitRequest">
      <data xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?> <crm:schedule_call_request session_id="mid://07060623130210031519@elnk_crm.com" target_system_id="csi_ivr" xmlns:crm="https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_crm.xsd" xmlns:xcommon="https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_common.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_crm.xsd https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_crm.xsd https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_common.xsd https://signup.earthlink.net/ws_xmlc/schema/crm/271005/xmlc_common.xsd"> <crm:call_parameter global_rules_version_id="" manual_request="true" originating_skillset="TS (DU/BB)|ADSL RETAIL" parameter_version_id="1" transfer_skillset="TSBBDSL...WinELNK"> <crm:call_id>10031519</crm:call_id> <crm:department_name>TS</crm:department_name> <crm:object_type>CASE</crm:object_type> <crm:object_id>73079085</crm:object_id> <crm:call_time>2007-06-07T12:30:01.000-08:00</crm:call_time> <crm:customer_phone_number>6263452656</crm:customer_phone_number> <crm:override_attempts>false</crm:override_attempts> <crm:retry_count>3</crm:retry_count> <crm:call_trigger>3000</crm:call_trigger> <crm:call_time_padding>10</crm:call_time_padding> <crm:override_local_customer_call_hours>false</crm:override_local_customer_call_hours> </crm:call_parameter> </crm:schedule_call_request></data>
      </ns1:SubmitRequest>
      </soapenv:Body>
      </soapenv:Envelope>

Maybe you are looking for

  • How do I extract my bookmarks from a copy of Firefox on another hard drive?

    My main computer died. Apparently power surge fried power supply and mother board. The hard drive was removed and using a USB adaptor I was able to copy the c-drive contents to an external back-up drive. I need the bookmarks file from the version on

  • Y axis is locked in 3d rotate. Suggestions.

    y axis is locked in 3d rotate. Suggestions.

  • IMac to Macbook sync

    I have a Macbook and is considering buying a iMac, I know i can use my mobile me account to sync the important stuff between the 2 computers but what about, iPhoto, iWeb, Aperture and iMovie. Is there a way to sync between the 2 computers with these

  • How to downgrade to ios5 from ios 6

    Does anyone know how to downgrade back from ios 6 to ios5?  I don't like ios 6, it is causing lots of issues, some of my apps are not working now and no youtube app. Thanks.

  • Processing WS-Security headers within a web service

    Hello, I have created a service with WS-Security (from a WSDL using jdeveloper) and deployed it on OC4J. Within the service implementation, I need to get some information from soap security header, that is, my service needs to process some security h