Hi,
i've got a problem with my web service. So here are my files:
First I wrote an xsd file:
Created my domain classes and wrote an endpoint:Code:<?xml version="1.0" encoding="utf-8"?> <schema targetNamespace="http://terminportal.org/webapp/ws/address" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:p="http://terminportal.org/webapp/ws/address"> <element name="Address"> <complexType> <sequence> <element name="Recipient" type="string" /> <element name="House" type="string" /> <element name="Street" type="string" /> <element name="Town" type="string" /> <element name="County" type="string" minOccurs="0" /> <element name="PostCode" type="string" /> <element name="Country"> <simpleType> <restriction base="string"> <enumeration value="FR" /> </restriction> </simpleType> </element> </sequence> </complexType> </element> </schema>
Code:<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping"> <property name="mappings"> <props> <prop key="{http://terminportal.org/webapp/ws/product}ProductRequest">ProductServiceEndpoint</prop> <prop key="{http://terminportal.org/webapp/ws/address}Address">AddressServiceEndpoint</prop> </props> </property>Now I'm trying to connect to this Endpoint via webserviceTemplate:Code:public class AddressServiceEndpoint extends AbstractMarshallingPayloadEndpoint { ...}
Heres the xml:Code:public AddressServiceClient(){ webServiceTemplate = new WebServiceTemplate(); webServiceTemplate.setDefaultUri("http://localhost:8080/wm2010-webservice/addressService"); } public void simpleSendAndReceive() { StreamSource source = new StreamSource(getClass().getResourceAsStream("/AddressServiceRequest.xml")); StreamResult result = new StreamResult(System.out); webServiceTemplate.sendSourceAndReceiveToResult(source, result); }
And now i get the following message running the addressserviceclient:Code:<?xml version="1.0" encoding="UTF-8"?> <Address xmlns="http://terminportal.org/webapp/ws/address"> <address> <post-code>8000</post-code> <town>Zurich</town> <house>76</house> <county>ZH</county> <country>CH</country> <street>Bahnhofstrasse</street> </address> </Address>
JAXB unmarshalling exception: unexpected element (uri:"http://terminportal.org/webapp/ws/address", local:"Address"). Expected elements are <{}Address>; nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://terminportal.org/webapp/ws/address", local:"Address"). Expected elements are <{}Address>
And I don't know wheres my fault. Has anyone an idea? It seems that the marshaller can't parse the namespace in the xml-file, but when the namespace is remove, the endpoint can't map the request.
Thanks for reading


Reply With Quote