Announcement Announcement Module
Collapse
No announcement yet.
problem in sending response of Marshall data...???? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem in sending response of Marshall data...????

    hello
    i have a class which extends with AbstractDomPayloadEndpoint and override the method
    protected Element invokeInternal(Element RootElement, Document document)
    {

    last return Dom Element as response..

    responseElement = document.createElement("getNodeListResponse");
    ....
    ...
    return responseElement;
    }


    now i facing a problem when i Marshall my object with JaxB
    ---------------
    My Marshall Response which i want to send

    <?xml version="1.0" encoding="UTF-8"?><Nodes><Nodename>telenor</Nodename><Nodename>Warid</Nodename><Nodename>Paktell</Nodename><nodename>telenor</nodename><nodename>Warid</nodename><nodename>Paktell</nodename></Nodes>

    ---------------
    now i create my response Element in invokeInternal() and get the Marshall data as a child in that response Element

    responseElement = document.createElement("getNodeListResponse");


    JAXBContext context = JAXBContext.newInstance(Nodes.class);
    Marshaller marshaller = context.createMarshaller();

    marshaller.marshal(Nodename, responseElement);
    }
    catch(Exception t)
    {
    t.printStackTrace();
    }

    now i get the xml which look like that
    ---------------------------------
    resultant response Element on client side...

    <?xml version="1.0" encoding="UTF-8"?><getNodeListResponse><Nodes><Nodename>telen or</Nodename><Nodename>Warid</Nodename><Nodename>Paktell</Nodename><nodename>telenor</nodename><nodename>Warid</nodename><nodename>Paktell</nodename></Nodes></getNodeListResponse>

    ----------------------
    now there is <getNodeListResponse> root element which added there so this not easy to unmarshall it on client side..

    i know i do mistake there i himself include the Marshall data as a child of ResponseElement but i have no way because Invokeinternal method take DOM.Element only


    so please Guide me how i only send my Marshall data as a response from my Webservice Endpoint class which use Invokeinternal method


    please that realy hard to understand me the sample example so just clue me how i do that

    hope somone help me

    waiting fr response

  • #2
    i got it.........



    try
    {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.newDocument();

    JAXBContext context = JAXBContext.newInstance(Nodes.class);
    Marshaller marshaller = context.createMarshaller();

    marshaller.marshal(Nodename, doc);

    responseElement=doc.getDocumentElement();
    }
    catch(Exception t)
    {
    t.printStackTrace();
    }

    i got the response Element with doing that

    marshaller.marshal(Nodename, doc); // doc is document which i created


    when result in doc than take

    responseElement=doc.getDocumentElement();

    ///////// sorry fr disturbing now alwayes Take care of documentation of any API.......................

    thanxxxx

    Comment

    Working...
    X