设置 WS 响应架构时出现问题
我正在使用soapUI 来测试一些WebServices。
在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>
我正在使用 Java 和 spring-ws。并使用 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>
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.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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在映射文件中,我必须将 ns-prefix 放入 map-to 元素中。
In the mapping file I have to put ns-prefix in the map-to element.