Announcement Announcement Module
Collapse
No announcement yet.
org.springframework.ws.soap.client.SoapFaultClient Exception: Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.ws.soap.client.SoapFaultClient Exception:

    Hi, Im getting the following exception:Im using saaj 1.3 version and also have added xecres 2.8.1 and xalan 2.7.0 to my pom.xml. Iwonder if it has to do with the endpoint(marked red)Please help
    Code:
    Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Class java.lang.String is of unrecognized type and cannot be added
    	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:37)
    	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:735)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:563)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:501)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:456)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:402)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:387)
    	at WebServiceClient.WSClient.simpleSendAndReceive(WSClient.java:25)
    	at WebServiceClient.Main.main(Main.java:12)
    Endpoint.java

    Code:
    public class Endpoint extends AbstractJDomPayloadEndpoint {
    	
    	private XPath messageExpression;
    	private final Business business;
    	
    
    	 public Endpoint(Business business) throws JDOMException {
              this.business=business;
              Namespace requestnamespace = Namespace.getNamespace("http://gid.com/div/request/schemas");
              messageExpression = XPath.newInstance("Message");
              messageExpression.addNamespace(requestnamespace);
              
    	 }
    
    	@Override
    	protected Element invokeInternal(Element Message) throws Exception {
    	
            String requestmessage= messageExpression.valueOf(Message);
            Namespace responseNamespace = Namespace.getNamespace(
            "http://gid.com/div/response/schemas");
            Element root = new Element("DivisionResponse", responseNamespace);
            Element divisionResponse = new Element("Response", responseNamespace);
            List<String>fetchedData=business.fetchData(requestmessage);
            divisionResponse.setContent(fetchedData);
            root.addContent(divisionResponse);
            Document doc = new Document(root);
            return doc.getRootElement();
    		}
    	}

    BusinessImpl.java
    Code:
    public class BusinessImpl implements Business{
    
    	private DivisionDao divisionDao;
    
    
    	public List<String> fetchData(String requestmessage) {
    		
    List<String> result= new ArrayList<String>();
    
    List<Division>listofdivisions=getDivisionDao().getAll();
    for(Division divisions:listofdivisions){
    		result.add(divisions.getDivision()+divisions.getName()+divisions.getOperational()+divisions.getValidFrom()+divisions.getValidTo());
    		
    		}
    	System.out.println(result); 
    	return result;
    	}
    
    
    public DivisionDao getDivisionDao()
    {
    	return divisionDao;
    }
    
    public void setDivisionDao(DivisionDao divisionDao){
    	
    	this.divisionDao=divisionDao;
    }
    }
    WSClient

    Code:
    public class WSClient  {
    	 public static final String MESSAGE =
    		 "<div:DivisionRequest xmlns:div=\"http://gid.com/div/request/schemas\">" +
    			"<div:Request>"+
    	        "<div:Message>FETCHDATA</div:Message>"+
             "</div:Request>"+
             "</div:DivisionRequest>";
    
           
    	
    	    public final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
            // send to the configured  URI
    	    public void simpleSendAndReceive() {
    	        StreamSource source = new StreamSource(new StringReader(MESSAGE));
    	        StreamResult result = new StreamResult(System.out);
    	       
    	        webServiceTemplate.sendSourceAndReceiveToResult("http://localhost:8080/SpringWebServiceGID/",source, result);
    	    }
    
    }
    spring-ws-servlet.xml

    Code:
    <bean id="Endpoint" class="serviceEndpoint.Endpoint">
            <constructor-arg ref="business"/>
        </bean>
    
        <bean id="business" class="serviceImpl.BusinessImpl">
    		<property name="divisionDao" ref="divisionDao" />
        </bean>
        
    
        <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
            <property name="mappings">
                <props>
                    <prop key="{http://gid.com/div/request/schemas}DivisionRequest">Endpoint</prop>
                </props>
            </property>
            <property name="interceptors">
                <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
            </property>
        </bean>
    Using SOAPUI to test I got

    Request
    Code:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://gid.com/div/request/schemas">
       <soapenv:Header/>
       <soapenv:Body>
          <sch:DivisionRequest>
             <sch:Request>
                <sch:Message>htyuij</sch:Message>
             </sch:Request>
          </sch:DivisionRequest>
       </soapenv:Body>
    </soapenv:Envelope>
    Response:
    Code:
    <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">Class java.lang.String is of unrecognized type and cannot be added</faultstring>
          </SOAP-ENV:Fault>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Last edited by ashleyvijay; Nov 25th, 2008, 08:58 AM.
Working...
X