Results 1 to 3 of 3

Thread: sending xml

  1. #1
    Join Date
    Apr 2008
    Posts
    21

    Default sending xml

    I am a relative newby to web services and I got my client working but I was wondering in a real world corporate environment how does the client pick up the xml? Is it send to a directory on the server? MQ? Email? If anyone has some example code for any of these types of xml retrievals or if you have documentation to point me to that would be greatly appreciated.

    Thanks
    gerbdla

  2. #2

    Default

    The choice of the transport medium between the client and the server is a matter of configuration in Spring-WS.
    Please refer to the Transports section in the reference doc for more details.
    Tareq Abedrabbo

    My Twitter
    My Blog

  3. #3
    Join Date
    Apr 2008
    Posts
    21

    Default thank you

    so which transport would I use if I were to drop an xml message into a directory? I read the section but it isn't clear to me. In the example I have
    it creates the xml on the fly and then sends it. If I want to use this client would I just read the xml in from a file system? Here is the client code which I am using from the example I have.

    package com.springinaction.poker.itest;

    import java.io.IOException;

    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.Namespace;
    import org.jdom.transform.JDOMResult;
    import org.jdom.transform.JDOMSource;
    import org.springframework.ws.client.core.WebServiceTempl ate;

    import com.springinaction.poker.Card;
    import com.springinaction.poker.PokerHandType;

    public class TemplateBasedPokerClient implements PokerClient {

    public PokerHandType evaluateHand(Card[] cards) throws IOException {

    // Construct message
    Element requestElement = new Element("EvaluateHandRequest");
    Namespace ns = Namespace.getNamespace("http://www.springinaction.com/poker/schemas");
    requestElement.setNamespace(ns);
    Document doc = new Document(requestElement);

    for (int i = 0; i < cards.length; i++) {
    Element cardElement = new Element("card");
    Element suitElement = new Element("suit");
    suitElement.setText(cards[i].getSuit().toString());
    Element faceElement = new Element("face");
    faceElement.setText(cards[i].getFace().toString());
    cardElement.addContent(suitElement);
    cardElement.addContent(faceElement);
    doc.getRootElement().addContent(cardElement);
    }

    // Send message
    JDOMSource requestSource = new JDOMSource(doc);
    JDOMResult result = new JDOMResult();

    webServiceTemplate.sendSourceAndReceiveToResult(re questSource, result);

    // Parse result
    Document resultDocument = result.getDocument();
    Element responseElement = resultDocument.getRootElement();
    Element handNameElement = responseElement.getChild("handName", ns);
    return PokerHandType.valueOf(handNameElement.getText());
    }

    // INJECTED
    private WebServiceTemplate webServiceTemplate;

    public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
    this.webServiceTemplate = webServiceTemplate;
    }
    }
    Last edited by gerbdla; Apr 28th, 2008 at 01:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •