*** Client Code 

   ...
...
...

public Element getProduct (String sku)
    throws SOAPException, MalformedURLException {
    Parameter skuParam;

    Call call =  new Call();
    call.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);

    call.setTargetObjectURI("urn:examples:XMLProductservice");
    call.setMethodName("getProduct");

    Vector paramList = new Vector();

    DocumentBuilder docBuilder = XMLParserUtils.getXMLDocBuilder();
    Document doc = docBuilder.newDocument();

    Element productNode = doc.createElement("product");
    productNode.setAttribute("sku", sku);

    skuParam = new Parameter("ProductNode", org.w3c.dom.Element.class,
                             productNode, Constants.NS_URI_LITERAL_XML);
    paramList.addElement(skuParam);
    call.setParams(paramList);

    URL url = new URL("http://localhost:8070/soap/servlet/rpcrouter";);

    Response resp = call.invoke(url,null);
...


***  Server Code

...
...

public Element getProduct (Element request)  {
    String sku = request.getAttribute("sku");
    ProductBean product = (ProductBean) products.get(sku);

    DocumentBuilder docBuilder = XMLParserUtils.getXMLDocBuilder();
    Document doc = docBuilder.newDocument();

    Text productNameText = doc.createTextNode(product.getName());
    Element nameNode = doc.createElement("name");
    nameNode.appendChild(productNameText);

    Text productDescriptionText = doc.createTextNode(product.getDescription());
    Element descriptionNode = doc.createElement("description");
    descriptionNode.appendChild(productDescriptionText);

    Text productPriceText = doc.createTextNode(Double.toString(product.getPrice()));
    Element priceNode = doc.createElement("price");
    priceNode.appendChild(productPriceText);

    Element productNode = doc.createElement("product");
    productNode.setAttribute("sku",sku);;
    productNode.appendChild(nameNode);
    productNode.appendChild(descriptionNode);
    productNode.appendChild(priceNode);
    return productNode;
  }

...
...


**

sample code from "Web ServicesEssentials"-Ethan Cerami


-----Original Message-----
From: Scott Nichol [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 16, 2002 12:51 PM
To: [EMAIL PROTECTED]
Subject: Re: Fault Occured


Exactly which sample are you running?  What is the command line you are
running?

Scott Nichol

----- Original Message -----
From: "???" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 15, 2002 11:42 PM
Subject: RE: Fault Occured


> Other samples work well..
>
> xerces: 2.2
> soap:2.3   &  2.2
> Apache Tomcat : 4.1
>
> i refered this site for installation..
http://www.scottnichol.com/apachesoapinstall.htm  :-)
>
> thanks a lot for your reply..
>
> -----Original Message-----
> From: Scott Nichol [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 16, 2002 2:49 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Fault Occured
>
>
> Do any other samples work?  What XML parser (+version)
> are you using?  What servlet container?  What
> instructions did you follow for the installation?
>
> Scott Nichol
>
> --- ??? <[EMAIL PROTECTED]> wrote:
> >
> >
> > I try to test sample SOAP code toworking with
> > literal XML documents..
> >
> > but..  Fault occured...
> >
> >
> > Fault Code:    SOAP-ENV:Server
> > Fault String:    Exception from service object:
> > org/apache/soap/util/xml/XMLParserUtils
> >
> >
> > Anybody can help me???
>
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


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


Reply via email to