了解spring-ws,与spring-mvc集成以及自动生成wsdl(understand spring-ws, integration with spring-mvc and automatic generation of wsdl)

我想学习spring-ws自动生成wsdl文件,我知道这是很多教程,我试过它们,我最喜欢的例子是:

github projet

它运作良好,但我试图为我的需求调整解决方案,它不起作用,我不知道为什么,这是你的问题,这里有什么问题?

我被改变了:

  • 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 :

github projet

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
2022-04-10 06:04

满意答案

不幸的是,对于所有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)

这是一个已知问题,请按照WEB-21022进行更新。 问题不是特定于webpack,唯一的解决方法是在启动应用程序之前手动运行webpack(通过运行配置或外部工具)。 请注意,仅在运行应用程序时,我无法在调试时重新创建它 It's a known issue, please follow WEB-21022 for updates. Problem is not specific to webpack, and the only workaround is running webpack man...

如何在WebStorm 2016.1.3中重新格式化没有文件扩展名的文件的源代码?(How can I reformat Source Code for files without file extension in WebStorm 2016.1.3?)

不幸的是,您无法在WebStorm中随时更改文件的文件类型。 可能的解决方法: 在项目的某个位置有一组文件(例如test.json , test.js等),您可以在其中复制粘贴此文件内容,将其重新格式化并将其复制回来。 使用“临时文件”功能 ( Tools | New Scratch File... ),然后使用相同的复制粘贴内容来重新格式化。 Unfortunately you cannot change file type of the file on the fly in WebStorm....

在WebStorm中使用Karma(Using Karma in WebStorm)

这是因为浏览器/客户端JavaScript中不存在require()。 你有三个选择: 使用标签。 使用CommmonJS实现。 Node.js等同步依赖关系使用AMD实现。 npm install requirejs 此选项将安装最新版本。 下载r.js. 如果你不想使用npm,你可以直接获得r.js: 从下载页面下载r.js并将其放入您的项目中。 从r.js repo获取源代码,并通过“node dist.js”生成r.js,或者从dist目录中获取快照。 用法 这些说明假定npm安装're...

手动代码重新格式化Webstorm中的异常?(Manual code-reformatting exceptions in Webstorm?)

不幸的是,对于所有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 JSON代码风格(Webstorm JSON code style)

在Intellij我去了这里,Webstorm可能是一样的...... In Intellij I go here, Webstorm might be the same...

WebStorm 6中的自动格式化代码类似于Sublime Text的Alignment Plugin(Auto-formatting Code in WebStorm 6 Akin to Sublime Text's Alignment Plugin)

代码格式设置在Settings (Preferences on Mac) | Code Style | JavaScript Settings (Preferences on Mac) | Code Style | JavaScript Settings (Preferences on Mac) | Code Style | JavaScript 。 Reformat Code只是一个命令,它根据这些规则重新格式化选择/文件。 JavaScript的代码样式有一个选项来进行这样的对齐: "Spac...

我如何才能保存在WebStorm中?(How can I TSLint on save in WebStorm?)

平台当前不支持保存操作,因为文件是由IDE自动保存的 - 请参阅https://youtrack.jetbrains.com/issue/IDEABKL-6722 。 如果需要在Save All上运行tslint --fix ,请将其设置为文件观察器,并禁用该观察器的即时同步 ,以便在显式保存/更改焦点时触发它。 查看下面最简单的配置...您需要根据您的本地设置更改程序字段 On-save actions are not currently supported by the platform, a...

如何在WebStorm中使用责任?(How to use blame in WebStorm?)

请参阅https://www.jetbrains.com/help/webstorm/2017.1/viewing-changes-information.html ,使用注释。 Annotate命令可从Version Control菜单的Subversion节点,Editor left gutter的上下文菜单,文件上下文菜单和文件历史记录视图中获得。 please see https://www.jetbrains.com/help/webstorm/2017.1/viewing-change...

WebStorm TypeScript导入格式选项(WebStorm TypeScript import formatting options)

Webstorm 2017.1有一个选项。 转至: Preferences | Editor | Code Style | Typescript | Wrapping and Braces Preferences | Editor | Code Style | Typescript | Wrapping and Braces Preferences | Editor | Code Style | Typescript | Wrapping and Braces滚动到底部并找到ES6 import/...

Webstorm上的文件完成(File completion at Webstorm)

似乎是在版本8修复。否则问题WEB-7566是一个很好的方式来看看 - 谢谢lena的提示! Seems to be fixed at Version 8. Otherwise Issue WEB-7566 is a good way to look at - Thanks lena for that hint!

相关文章

更多

使用spring-integration-kafka操作kafka

依赖 &lt;dependency&gt; &lt;groupId&gt;org.springf ...

Spring MVC 3 深入总结

一、前言: 大家好,Spring3 MVC是非常优秀的MVC框架,由其是在3.0版本发布后,现在有越来 ...

Spring MVC入门

我们所讲的内容包含了springmvc的所有最常用的最实用的知识点,通过我们的学习,我们使用sprin ...

Spring MVC与表单提交的问题

1.model: public class UserType implements Serializ ...

深入解析Spring MVC与Web Flow

深入解析Spring MVC与Web Flow的内容摘要:英文版:Expert Spring MVC ...

请教关于spring mvc中使用json-lib-ext-spring返回json的问题

我做了一个这样的框架: spring+hibernate+spring mvc 想让spring ...

spring mvc 页面传值到controller

一个页面上有很多输入框,我想把这些值通过json格式传到controller中,通过注解应该如何实现? ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本