Announcement Announcement Module
Collapse
No announcement yet.
Spring WebService - Unable to create envelope from given source Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 com.sp.ag.ws.test.TestService.main(TestService.jav a:27)




    Code:
    public class IssuerEndpoint extends AbstractMarshallingPayloadEndpoint {
    	private static Logger logger=Logger.getLogger(IssuerEndpoint.class);
    	private IssuerService issuerService;
    
    	
    	public IssuerEndpoint(IssuerService issuerService, Marshaller marshaller) {
    		super(marshaller);
    		this.issuerService = issuerService;
    	}
    
    	@Override
    	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
    		while(iterator.hasNext()){
    		
    			IssueSchemaType data=responseDoc.addNewShowIssue().addNewDataArea().addNewIssue();
    			Issuer issuer=(Issuer) iterator.next();
    			data.addNewID().setStringValue(issuer.getId());
    			data.addNewName().setStringValue(issuer.getName());
    			data.addNewNameAlias().setStringValue("Alias Name");
    			data.setStreet1(issuer.getStreet1());
    			data.setStreet2(issuer.getStreet2());
    			data.setState(issuer.getState());
    			data.setCity(issuer.getCity());
    			data.setCountry(issuer.getCountry());
    			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) {
    	    	
    	    	webServiceTemplate.setDefaultUri(defaultUri);
    	    	webServiceTemplate.setMarshaller(marshaller);
    	    	webServiceTemplate.setUnmarshaller(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:

    Code:
    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.

    Comment


    • #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?

      Comment


      • #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.

        Comment


        • #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.

          Comment


          • #6
            Hi

            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="com.mycompany.hr.ws.HolidayEndpointWithXMLB eans">
            <constructor-arg ref="marshaller"></constructor-arg>
            </bean>


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

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

            e.printStackTrace();
            }

            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>

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

            <bean id="holidayEndpoint" class="com.mycompany.hr.ws.HolidayEndpointWithXMLB eans">
            <constructor-arg ref="marshaller"></constructor-arg>
            </bean>



            With this configuration I am getting the following SOAPFault:
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
            <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
            <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Server</faultcode>
            <faultstring xml:lang="en">Can't overwrite cause</faultstring>
            </SOAP-ENV:Fault>
            </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>

            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...

            Comment


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

              Comment

              Working...
              X