いくつかの Web サービスをテストするために soapUI を使用しています。
soapUI で利用可能な MockService では、このデフォルトの応答を取得します
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.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>
実際の Web サービスが呼び出されたときに xmlns:sch="http://www.someurl.com/schemas" が表示されず、応答内の要素に「sch」プレフィックスが付いていません。ここに私が得るものがあります:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<Response>
<Something>something</Something>
</Response>
</soapenv:Body>
</soapenv:Envelope>
spring-ws で Java を使用しています。また、Castor を使用して xml を Java オブジェクトにマーシャリングします。
応答にスキーマを含める方法は?
編集: 構成の詳細を追加します。
myApplication-servlet.xml はこのようなものです
<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>