Trouble setting WS response schema
I'm using soapUI to test some WebServices.
In MockService available in soapUI I get this default response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.开发者_Go百科org/soap/envelope/" xmlns:sch="http://www.someurl.com/schemas">
<soapenv:Header/>
<soapenv:Body>
<sch:Response>
<sch:Something>?</sch:Something>
</sch:Response>
</soapenv:Body>
</soapenv:Envelope>
When the real Webservice is called I don't get xmlns:sch="http://www.someurl.com/schemas" and the elements inside the response doesn't come with 'sch' prefix. Here is what I get:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<Response>
<Something>something</Something>
</Response>
</soapenv:Body>
</soapenv:Envelope>
I'm using Java with spring-ws. And using Castor to marshall xml to Java Object.
How to include the schema in the response?
EDIT: Adding configuration details.
myApplication-servlet.xml is like this
<bean id="payloadMapping"
class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="endpointMap">
<map>
<entry
key="{http://www.someurl.com/schemas}MyRequest"
value-ref="myEndpoint"/>
</map>
</property>
</bean>
<bean id="myEndpoint"
class="foo.bar.myEndpoint">
<constructor-arg ref="messageSource" />
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
</bean>
<bean id="myWsdlDefinition"
class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schema">
<bean class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/MyXsd.xsd" />
</bean>
</property>
<property name="portTypeName" value="myPortTypeName" />
<property name="locationUri" value="http://anotherUrl:8080/services" />
</bean>
<bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller">
<property name="mappingLocation" value="classpath:mapping.xml" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="errors" />
</bean>
In the mapping file I have to put ns-prefix in the map-to element.
<map-to xml="Response" ns-prefix="sch" />
精彩评论