了解spring-ws,与spring-mvc集成以及自动生成wsdl(understand spring-ws, integration with spring-mvc and automatic generation of wsdl)
我想学习spring-ws自动生成wsdl文件,我知道这是很多教程,我试过它们,我最喜欢的例子是:
它运作良好,但我试图为我的需求调整解决方案,它不起作用,我不知道为什么,这是你的问题,这里有什么问题?
我被改变了:
- models(github项目中的oxm包) - schema.xsd(github项目中的ecommerce.xsd)以及
- EndpointClass
- 删除类:SubscriptionPort.java和SubscriptionPortService.java(我注意到正确操作不需要)(从github项目中删除时一切都很好)
我生成的wsdl文件没有wsdl:operation标签(应该在PortType标签中)...
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://localhost:8080/ws/schema/oss" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8080/ws/schema/oss" targetNamespace="http://localhost:8080/ws/schema/oss"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://localhost:8080/ws/schema/oss" version="1.0"> <xs:complexType name="deliverShortMessageRequest"> <xs:sequence> <xs:element minOccurs="0" name="parameters"> <xs:complexType> <xs:sequence> <xs:element name="sms" type="tns:deliverShortMessage"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessageResponse"> <xs:sequence> <xs:element name="deliverShortMessageReturn" type="xs:boolean"/> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessage"> <xs:sequence> <xs:element minOccurs="0" name="sms" type="tns:smsMessage"/> </xs:sequence> </xs:complexType> <xs:complexType name="smsMessage"> <xs:sequence> <xs:element minOccurs="0" name="content" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:portType name="SubscriptionPort"></wsdl:portType> <wsdl:binding name="SubscriptionPortSoap11" type="tns:SubscriptionPort"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> <wsdl:service name="SubscriptionPortService"> <wsdl:port binding="tns:SubscriptionPortSoap11" name="SubscriptionPortSoap11"> <soap:address location="/"/> </wsdl:port> </wsdl:service>
schema.xml中
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified" targetNamespace="http://localhost:8080/ws/schema/oss" xmlns:tns="http://localhost:8080/ws/schema/oss"> <xs:complexType name="deliverShortMessageRequest"> <xs:sequence> <xs:element name="parameters" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="sms" type="tns:deliverShortMessage"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessageResponse"> <xs:sequence> <xs:element name="deliverShortMessageReturn" type="xs:boolean"/> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessage"> <xs:sequence> <xs:element name="sms" type="tns:smsMessage" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="smsMessage"> <xs:sequence> <xs:element name="content" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema>
我的简单端点类:
@Endpoint public class MessageEndpoint { private static final String NAMESPACE_URI = "http://localhost:8080/ws/schema/oss"; @PayloadRoot(namespace = NAMESPACE_URI, localPart = "DeliverShortMessageRequest") @ResponsePayload public DeliverShortMessageResponse deliverShortMessage(@RequestPayload DeliverShortMessageRequest deliverShortMessageRequest) { System.out.println("deliverShortMessage " + deliverShortMessageRequest); DeliverShortMessageResponse result = new DeliverShortMessageResponse(); result.setDeliverShortMessageReturn(true); return result; } }
spring-ws config:
<sws:annotation-driven /> <sws:interceptors> <bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor" p:schema="/WEB-INF/schema.xsd" p:validateRequest="true" p:validateResponse="true"/> <bean id="loggingInterceptor" class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/> </sws:interceptors> <sws:dynamic-wsdl id="subscription" portTypeName="SubscriptionPort" locationUri="/" targetNamespace="http://localhost:8080/ws/schema/oss"> <sws:xsd location="/WEB-INF/schema.xsd"/> </sws:dynamic-wsdl> <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" p:contextPath="org.krams.tutorial.model"/> <bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor"> <constructor-arg ref="jaxbMarshaller"/> <constructor-arg ref="jaxbMarshaller"/> </bean> <bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter"> <property name="methodArgumentResolvers"> <list> <ref bean="marshallingPayloadMethodProcessor"/> </list> </property> <property name="methodReturnValueHandlers"> <list> <ref bean="marshallingPayloadMethodProcessor"/> </list> </property> </bean>
当我搜索答案为什么会发生这种情况时,我发现了像: Spring-WS生成WSDL而没有操作 Spring-WS WSDL生成问题,但是你可以看到我的请求和响应对象有Request和Response后缀
你有什么想法我忘记了吗? 为什么在wsdl我没有操作标签? 看起来他没有看到Endpoint操作或者有一些字母不匹配
i want learn spring-ws with automatic generation of wsdl files, i know that is a lot of tutorials, i tried them, my favorite example is :
It works well, but i tried to ajust that solution for my needs, and it doesnt work, i dont know why, and it is question for you, what is wrong here?
I was changed:
- models (oxm package in github project) - schema.xsd (ecommerce.xsd in github project) as well
- EndpointClass
- remove classes: SubscriptionPort.java and SubscriptionPortService.java (I noticed that are not needed for proper operation) (when remove from github project everything was good)
and my generated wsdl file have no wsdl:operation tag (should be in PortType tag)...
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://localhost:8080/ws/schema/oss" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8080/ws/schema/oss" targetNamespace="http://localhost:8080/ws/schema/oss"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://localhost:8080/ws/schema/oss" version="1.0"> <xs:complexType name="deliverShortMessageRequest"> <xs:sequence> <xs:element minOccurs="0" name="parameters"> <xs:complexType> <xs:sequence> <xs:element name="sms" type="tns:deliverShortMessage"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessageResponse"> <xs:sequence> <xs:element name="deliverShortMessageReturn" type="xs:boolean"/> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessage"> <xs:sequence> <xs:element minOccurs="0" name="sms" type="tns:smsMessage"/> </xs:sequence> </xs:complexType> <xs:complexType name="smsMessage"> <xs:sequence> <xs:element minOccurs="0" name="content" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:portType name="SubscriptionPort"></wsdl:portType> <wsdl:binding name="SubscriptionPortSoap11" type="tns:SubscriptionPort"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> </wsdl:binding> <wsdl:service name="SubscriptionPortService"> <wsdl:port binding="tns:SubscriptionPortSoap11" name="SubscriptionPortSoap11"> <soap:address location="/"/> </wsdl:port> </wsdl:service>
schema.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified" targetNamespace="http://localhost:8080/ws/schema/oss" xmlns:tns="http://localhost:8080/ws/schema/oss"> <xs:complexType name="deliverShortMessageRequest"> <xs:sequence> <xs:element name="parameters" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="sms" type="tns:deliverShortMessage"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessageResponse"> <xs:sequence> <xs:element name="deliverShortMessageReturn" type="xs:boolean"/> </xs:sequence> </xs:complexType> <xs:complexType name="deliverShortMessage"> <xs:sequence> <xs:element name="sms" type="tns:smsMessage" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="smsMessage"> <xs:sequence> <xs:element name="content" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema>
my simple Endpoint class:
@Endpoint public class MessageEndpoint { private static final String NAMESPACE_URI = "http://localhost:8080/ws/schema/oss"; @PayloadRoot(namespace = NAMESPACE_URI, localPart = "DeliverShortMessageRequest") @ResponsePayload public DeliverShortMessageResponse deliverShortMessage(@RequestPayload DeliverShortMessageRequest deliverShortMessageRequest) { System.out.println("deliverShortMessage " + deliverShortMessageRequest); DeliverShortMessageResponse result = new DeliverShortMessageResponse(); result.setDeliverShortMessageReturn(true); return result; } }
spring-ws config:
<sws:annotation-driven /> <sws:interceptors> <bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor" p:schema="/WEB-INF/schema.xsd" p:validateRequest="true" p:validateResponse="true"/> <bean id="loggingInterceptor" class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/> </sws:interceptors> <sws:dynamic-wsdl id="subscription" portTypeName="SubscriptionPort" locationUri="/" targetNamespace="http://localhost:8080/ws/schema/oss"> <sws:xsd location="/WEB-INF/schema.xsd"/> </sws:dynamic-wsdl> <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" p:contextPath="org.krams.tutorial.model"/> <bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor"> <constructor-arg ref="jaxbMarshaller"/> <constructor-arg ref="jaxbMarshaller"/> </bean> <bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter"> <property name="methodArgumentResolvers"> <list> <ref bean="marshallingPayloadMethodProcessor"/> </list> </property> <property name="methodReturnValueHandlers"> <list> <ref bean="marshallingPayloadMethodProcessor"/> </list> </property> </bean>
When I searching an answers why it is happening I found replice like: Spring-WS generates WSDL without operations Spring-WS WSDL Generation Problem but as you can see my request and response objects have Request and Response suffix
do you have any ideas what i forgot? and why in wsdl i have no operation tag? it looks like he doesnt see Endpoint operation or there is some letter mismatch
原文:https://stackoverflow.com/questions/30915718
满意答案
不幸的是,对于所有3个问题,答案都是'不':(请随时向WebStorm问题跟踪器提交这些功能的请求
Unfortunately the answer is 'no' for all 3 questions:( Please feel free to file requests for these features to WebStorm issue tracker
相关问答
更多WebStorm“发布之前” - 等待完成(WebStorm “Before Launch” – Wait for completion)
如何在WebStorm 2016.1.3中重新格式化没有文件扩展名的文件的源代码?(How can I reformat Source Code for files without file extension in WebStorm 2016.1.3?)
在WebStorm中使用Karma(Using Karma in WebStorm)
手动代码重新格式化Webstorm中的异常?(Manual code-reformatting exceptions in Webstorm?)
Webstorm JSON代码风格(Webstorm JSON code style)
WebStorm 6中的自动格式化代码类似于Sublime Text的Alignment Plugin(Auto-formatting Code in WebStorm 6 Akin to Sublime Text's Alignment Plugin)
我如何才能保存在WebStorm中?(How can I TSLint on save in WebStorm?)
如何在WebStorm中使用责任?(How to use blame in WebStorm?)
WebStorm TypeScript导入格式选项(WebStorm TypeScript import formatting options)
Webstorm上的文件完成(File completion at Webstorm)
相关文章
更多使用spring-integration-kafka操作kafka
Spring MVC 3 深入总结
Spring MVC入门
Spring MVC与表单提交的问题
深入解析Spring MVC与Web Flow
请教关于spring mvc中使用json-lib-ext-spring返回json的问题
spring mvc 页面传值到controller
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!