gpt4 book ai didi

java struts2 hibernate和spring应用程序和soap web服务

转载 作者:行者123 更新时间:2023-12-02 06:21:44 25 4
gpt4 key购买 nike

我有一个使用 struts2、spring 和 hibernate 框架的 Web 应用程序。现在我想通过soap web 服务公开它的一些方法。我有一个类,我只是用 @WebService 注释和服务端点接口(interface)对其进行了注释。现在,当我在 glassfish 上部署应用程序时,它部署得很好,但是当我尝试通过 glasssfish 管理控制台访问 wsdl 时。它给了我以下错误。

There is no Action mapped for namespace [/] and action name [UsersControllerImplService] associated with context path [/ossoc].

我了解它与配置相关的内容,但我无法弄清楚是什么配置。

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">

<display-name>ossoc</display-name>


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

</web-app>

struts2.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.objectFactory" value="spring" />

<package name="user" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="authentication" class="com.riteshsangwan.ossoc.core.interceptors.AuthenticationInterceptor"></interceptor>
<interceptor-stack name="authStack">
<interceptor-ref name="authentication"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="authStack"></default-interceptor-ref>

<global-results>
<result name="login" type="redirect">/index.action</result>
</global-results>

<action name="register" class="com.riteshsangwan.ossoc.core.actions.RegisterAction">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/index.jsp</result>
<result name="error">/register.jsp</result>
<result name="input">/register.jsp</result>
</action>

<action name="login" class="com.riteshsangwan.ossoc.core.actions.LoginAction">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/user/home.jsp</result>
<result name="error">/index.jsp</result>
<result name="input">/index.jsp</result>
</action>

<action name="activate" class="com.riteshsangwan.ossoc.core.actions.ActivateAction">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success">/user/home.jsp</result>
<result name="error">/index.jsp</result>
<result name="input">/index.jsp</result>
</action>



<action name="index">
<interceptor-ref name="defaultStack"></interceptor-ref>
<result>/index.jsp</result>
</action>

<action name="home">
<result>/user/home.jsp</result>
</action>

<action name="showfiles" class="com.riteshsangwan.ossoc.core.actions.ShowFiles">
<result name="success">/user/files.jsp</result>
</action>

<action name="edit">
<result>/user/edit.jsp</result>
</action>

<action name="logout" class="com.riteshsangwan.ossoc.core.actions.LogoutAction">
<result name="success">/index.jsp</result>
</action>

<action name="changepassword" class="com.riteshsangwan.ossoc.core.actions.ChangePassword">
<result name="success">/user/edit.jsp</result>
</action>

<action name="upload" class="com.riteshsangwan.ossoc.core.actions.UploadFile">
<result>/user/home.jsp</result>
</action>

<action name="showgrid" class="com.riteshsangwan.ossoc.core.actions.ShowFiles">
<result name="success">/user/files.jsp</result>
</action>

<action name="deletefile" class="com.riteshsangwan.ossoc.core.actions.DeleteFile">
<result name="success">/user/files.jsp</result>
</action>

<action name="downloadfile" class="com.riteshsangwan.ossoc.core.actions.DownloadFile">
<result name="success" type="stream">
<param name="contentType"></param>
<param name="inputName"></param>
<param name="contentDisposition"></param>
<param name="bufferSize"></param>
<param name="allowCaching"></param>
<param name="contentLength"></param>
</result>
</action>

</package>

</struts>

applicationCOntext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />


<!-- Database Configuration -->

<import resource="DataSource.xml"/>
<import resource="HibernateSessionFactory.xml"/>

<!-- Beans Declaration -->
<import resource="UsersBean.xml"/>

</beans>

最佳答案

为什么这里的每个人都如此渴望投票否决。

这就是问题所在。在 web.xml 中,struts2 过滤器映射了 /* url 模式,因此 struts2 将过滤到达它的每个请求,包括对 webservice servlet 的请求。由于过滤器在 servlet 之前执行,因此我收到了操作未映射错误。来自struts2文档。 Action 映射扩展名已更改为 .action 加“”,这意味着如果我只需在地址栏中输入 servlet 的名称,struts2 会将其视为 Action 并检查 struts2.xml 中是否有相关 Action 映射,因为没有 Action 映射,因此它会抛出错误。

解决方案我只是在 URL 模式映射中的 url 之后添加 .extension,这样 struts2 就会将其视为 servlet 请求,其他选项将使用

<constant name="struts.action.excludePattern" value="URLTOEXCLUDE"/> 
and configure the webservice to use the excluded URL

希望这对其他人有帮助。

关于java struts2 hibernate和spring应用程序和soap web服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20955026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com