Title: How to pass Element argument
Yong,
  I'm not quite sure. There might be an issue with the element that you are retrieving from your document. Here is the code that works fine for me:
 
 
 //Get handle to Document Builder Factory.
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
 
 //Create a new document builder.
 DocumentBuilder tempBuilder = factory.newDocumentBuilder(); 
 Document tempDocument = null;
 tempDocument = tempBuilder.newDocument();
 Element inputNode = tempDocument.createElement("InputParams");
 inputNode.setAttribute("partnerName",partnerName);
 
 
-----Original Message-----
From: Yong Miao [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 15, 2002 11:17 AM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: How to pass Element argument

What's wrong?

 

 

Service descriptor:

<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"

             id="urn:test-service">

  <isd:provider type="java"

                scope="Application"

                methods="createOrder"

  >

    <isd:java class="TestService" static="false" />

  </isd:provider>

 

  <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>

</isd:service>

 

Here's the service look like:

 

    public String createOrder(Element orderReq)

    {

      // check input params

      if( orderReq == null)

      {

        throw new IllegalArgumentException("The orderReq cannot be null.");

      }

 

      // process order

      boolean ret = processor.process(orderReq);

      if(ret)

        return "1";

      else

        return "0";

    }

 

Here's the client calling the service:

        DocumentBuilder builder = XMLParserUtils.getXMLDocBuilder();

        Document doc = builder.parse(new FileInputStream(xmlFile));

 

        // Build the Call object

        Call call = new Call();

        call.setTargetObjectURI("urn:test-service");

        call.setMethodName("createOrder");

        call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);

 

        // Set up parameters

        Vector params = new Vector();

        params.addElement(new Parameter("orderReq", Element.class, doc.getDocumentElement(), Constants.NS_URI_LITERAL_XML));

        call.setParams(params);

 

        // Invoke the call

        Response response;

        response = call.invoke(url, "");

Regards,
-----------------------------
Yong Miao
Aspentech Bothell
-----------------------------

-----Original Message-----
From: Miguel Perez [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 15, 2002 9:10 AM
To: '
[EMAIL PROTECTED]'
Subject: RE: How to pass Element argument

 

What does your code look like? It appears that you are trying to pass something other than an Element type to your service?

 

Miguel

-----Original Message-----
From: Yong Miao [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 15, 2002 11:07 AM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: How to pass Element argument

Miguel,

 

Thanks for the reply. I still got error like:

java.lang.IllegalArgumentException: I only know how to serialize an 'org.w3c.dom.Element'.

[SOAPException: faultCode=SOAP-ENV:Server; msg=java.lang.IllegalArgumentException: I only know how to serialize an 'org.w3c.dom.Element'.]

 

I wonder if there's something to do with the service mapping. I am not sure what and how to do.

Something like XMLParameterSerializer.

Regards,
-----------------------------
Yong Miao
[EMAIL PROTECTED]

-----------------------------

-----Original Message-----
From: Miguel Perez [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 15, 2002 8:57 AM
To: '[EMAIL PROTECTED]'
Subject: RE: How to pass Element argument

 

  call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
  
 Element inputNode = tempDocument.createElement("InputParams");
 inputNode.setAttribute("partnerName",partnerName);
  
  params = new java.util.Vector();
  params.addElement(new Parameter("productinformation",Element.class,inputNode,Constants.NS_URI_LITERAL_XML));

-----Original Message-----
From: Yong Miao [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 15, 2002 10:48 AM
To: [EMAIL PROTECTED]
Subject: How to pass Element argument

Hi,

I have a service that requires DOM Element as input. There's no mapping for the service.

How should I a DOM Element variable to the service from client?

I got errors like this:

[SOAPException: faultCode=SOAP-ENV:Client; msg=No Serializer found to serialize a 'org.w3c.dom.Element' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.; targetException=java.lang.IllegalArgumentException: No Serializer found to serialize a 'org.w3c.dom.Element' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]

        at org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.java:324)

        at org.apache.soap.rpc.Call.invoke(Call.java:205)

        at OrderClient.placeOrder(OrderClient.java:44)

        at OrderClient.main(OrderClient.java:83)

Thanks,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Yong Miao

[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to