Results 1 to 2 of 2

Thread: webservice client got error: the root element is not named "Envelope"

  1. #1
    Join Date
    Oct 2007
    Posts
    7

    Default webservice client got error: the root element is not named "Envelope"

    I am using Spring WS 1.5.9. I made a client to call a webservice. First I got the error:

    com.sun.istack.internal.SAXException2: unable to marshal type "com.xyz.FooRequestType" as an element because it is missing an @XmlRootElement annotation

    Then I changed the code to use ObjectFactory to create a JAXBElement request. The new code is like the following:

    FooRequestType request = new FooRequestType();
    request.setXXX(....)

    com.xyz.ObjectFactory objFactory = new ObjectFactory();
    JAXBElement<FooRequestType> jaxbRequest = objFactory
    .createFooRequest(request);

    FooResponseType response = (FooResponseType) webServiceTemplate
    .marshalSendAndReceive(request);


    But then I got the following error:


    Jun 15, 2011 4:58:53 PM com.sun.xml.messaging.saaj.soap.SOAPPartImpl lookForEnvelope
    SEVERE: SAAJ0514: Unable to create envelope from given source because the root element is not named Envelope
    Jun 15, 2011 4:58:53 PM com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope
    SEVERE: SAAJ0511: Unable to create envelope from given source
    org.springframework.ws.soap.saaj.SaajSoapMessageEx ception: Could not access envelope: Unable to create envelope from given source: ; nested exception is com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
    at org.springframework.ws.soap.saaj.support.SaajUtils .getSaajVersion(SaajUtils.java:162)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etImplementation(SaajSoapMessage.java:251)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.< init>(SaajSoapMessage.java:84)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.< init>(SaajSoapMessage.java:70)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:168)
    at org.springframework.ws.transport.AbstractWebServic eConnection.receive(AbstractWebServiceConnection.j ava:90)
    at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:553)
    at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:502)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 351)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 345)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 337)
    at examples.TonyWebServiceClient.testGetCommodities(T onyWebServiceClient.java:58)
    at examples.TonyWebServiceClient.main(TonyWebServiceC lient.java:87)
    Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
    at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.cr eateEnvelope(EnvelopeFactory.java:148)
    at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1 Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java :102)
    at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEn velope(SOAPPartImpl.java:156)
    at org.springframework.ws.soap.saaj.support.SaajUtils .getSaajVersion(SaajUtils.java:159)
    ... 12 more
    Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source because the root element is not named "Envelope"
    at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.lookF orEnvelope(SOAPPartImpl.java:182)
    at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEn velope(SOAPPartImpl.java:149)
    at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.cr eateEnvelope(EnvelopeFactory.java:138)
    ... 15 more


    Anybody knows any solutions?

    By the way, the following is the applicationContext.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/oxm
    http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
    <bean id="webserviceTemplate" class="org.springframework.ws.client.core.WebServi ceTemplate">
    <property name="defaultUri"
    value="http://someWebService.wsdl" />
    <property name="marshaller" ref="marshaller" />
    <property name="unmarshaller" ref="marshaller" />

    </bean>
    <oxm:jaxb2-marshaller id="marshaller"
    contextPath="com.xyz" />
    </beans>

  2. #2
    Join Date
    Apr 2011
    Posts
    7

    Default

    Me also facing same error..can any body help what is the wrong or we missing

Tags for this Thread

Posting Permissions

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