FileDocCategorySizeDatePackage
ProductXMLService.javaAPI DocExample2185Tue Oct 09 11:03:40 BST 2001com.ecerami.soap

ProductXMLService

public class ProductXMLService extends ProductService
A Sample SOAP Service Provides Product Name for requested Stockkeeping Unit (SKU) Information is passed as Literal XML Documents.

Fields Summary
Constructors Summary
Methods Summary
public org.w3c.dom.ElementgetProduct(org.w3c.dom.Element request)
Provides Product Info. for requested XML document.

    //  Extract sku attribute
    String sku = request.getAttribute("sku");
    ProductBean product = (ProductBean) products.get(sku);

    //  Create XML Document to store Product data
    DocumentBuilder docBuilder = XMLParserUtils.getXMLDocBuilder();
    Document doc = docBuilder.newDocument();

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

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

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

    // Create Root Product Element
    Element productNode = doc.createElement("product");
    productNode.setAttribute("sku", sku);
    productNode.appendChild(nameNode);
    productNode.appendChild(descriptionNode);
    productNode.appendChild(priceNode);
    return productNode;