Announcement Announcement Module
No announcement yet.
Spring WebService - Unable to create envelope from given source Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring WebService - Unable to create envelope from given source

    Here I am pasting my Endpoint code.

    It is construncting the response object but it is throwing following exception

    Oct 4, 2007 6:27:27 PM com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope
    SEVERE: SAAJ0511: Unable to create envelope from given source
    Exception in thread "main" java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlAnyTypeImpl
    at a:27)

    public class IssuerEndpoint extends AbstractMarshallingPayloadEndpoint {
    	private static Logger logger=Logger.getLogger(IssuerEndpoint.class);
    	private IssuerService issuerService;
    	public IssuerEndpoint(IssuerService issuerService, Marshaller marshaller) {
    		this.issuerService = issuerService;
    	protected Object invokeInternal(Object request) throws Exception {
    		ShowIssueDocument issueDoc=(ShowIssueDocument)request;
    		logger.debug("Request XML:"+ issueDoc.xmlText());
    		String authrozationId=issueDoc.getShowIssue().getApplicationArea().getSender().getAuthorizationID().getStringValue();
    		logger.debug("Authorization Id:"+authrozationId);
    		//This will call the Issuer Business Service
    		List issuerList=this.issuerService.getIssuerList(authrozationId);
    		ShowIssueDocument responseDoc=ShowIssueDocument.Factory.newInstance();
    		Iterator iterator=issuerList.iterator();
    		// Creating the resonse object
    			IssueSchemaType data=responseDoc.addNewShowIssue().addNewDataArea().addNewIssue();
    			Issuer issuer=(Issuer);
    			data.addNewNameAlias().setStringValue("Alias Name");
    			data.setZip(new BigInteger(issuer.getZip().toString()));
    		System.out.println("Response XML:"+responseDoc.xmlText());
    		logger.debug("Response XML:"+responseDoc.xmlText());
    		return responseDoc;
    public class WebServiceClient {
    	private static Logger logger=Logger.getLogger(WebServiceClient.class);
    	 private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
    	    public WebServiceClient(String defaultUri, Marshaller marshaller, Unmarshaller unmarshaller) {
    	     * @param xmlObject It will take XmlObject as input parameter
    	     * @return Object 
    	     * @since send to the configured default URI
    	    public Object simpleSendAndReceive(XmlObject xmlObject) {
    	    	return webServiceTemplate.marshalSendAndReceive(xmlObject);

  • #2
    I'm guessing here, but I think the offending line (no 27) is:

    ShowIssueDocument issueDoc=(ShowIssueDocument)request;
    This means that the XMLBeansMarshaller, which I guess you use, does not create a ShowIssueDocument, but something else instead. It might help to debug your service, and find out what the request object really is.


    • #3
      Same ClassCast exception

      My web service is throwing a ClassCastException in the very same place as the previous post. Funny thing is it work fine on my desktop Weblogic 9.2 server but shows the error consistantly on a Linux Weblogic 9.2 server.

      Printing out the 'request' just prior to the cast shows exactly the same XML structure.

      How can this be diagnosed?


      • #4
        I am getting exactly the same issue Exception:org.apache.xmlbeans.impl.values.XmlAnyTy peImpl. It seems as if the XMLBeansMarshaller is not finding the document beans the I have generated.

        Unfortunately I am unable to debug into the spring code to see what is going on. I have a breakpoint in my endpoint class and it clearly shows XmlAnyTypeImpl being passed as a parameter into the following method.

        protected Object invokeInternal(Object request){
        return request;

        Does anyone have any ideas on this issue.


        • #5
          java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlAnyTypeImpl

          This exception is thrown when you have compiled your XML schema with one version of Xmlbeans but you use another version of Xmlbeans in your application.

          Check that you use the same xmlbeans.jars in the both cases.


          • #6

            I was facing the same problem. Then i did some modifications to my spring-ws-servlet.xml file and started getting some new error.

            This was my earlier configuration in the spring-ws-servlet.xml file:
            <bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMa rshaller" />

            <bean id="holidayEndpoint" class=" eans">
            <constructor-arg ref="marshaller"></constructor-arg>

            This is the invokeInternal method of my endpoint class:
            protected Object invokeInternal(Object arg0) throws Exception {

            HolidayRequestDocument requestDoc = (HolidayRequestDocument)arg0;
            }catch (Exception e){


            With this above configuration I was getting ClassCastException as pointed in other posts.

            Then I read the javadocs related to XMLBeansMarshaller and changed my spring-ws-servlet.xml file to supply XMLOptions to the marsahller.
            This is the new configuration in my spring-ws-servlet.xml file:
            <bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMa rshaller" >
            <property name="xmlOptions" ref="xmlOptions" />

            <bean id="xmlOptions" class="org.springframework.oxm.xmlbeans.XmlOptions FactoryBean">
            <property name="options">
            <prop key="DOCUMENT_TYPE"> ayRequestDocument.type</prop>

            <bean id="holidayEndpoint" class=" eans">
            <constructor-arg ref="marshaller"></constructor-arg>

            With this configuration I am getting the following SOAPFault:
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="">
            <faultstring xml:lang="en">Can't overwrite cause</faultstring>

            I tried debugging, but with this new configuration execution is not even going to the invokeInternal method of my endpoint.

            Is my new configuration correct?
            How to resolve this error?

            Thanks in advance...


            • #7
              I suggest you post a new note. This obviously has nothing to do with the original subject.