2014-01-06 3 views
0

У меня есть веб-приложение, использующее рамки struts2, spring и hibernate. Теперь я хочу разоблачить некоторые из его методов с помощью мыльного веб-сервиса. У меня есть класс, и я просто аннотировал его с помощью аннотации @WebService и интерфейса конечной точки службы. Теперь, когда я развертываю свое приложение на стеклянной планете, он развертывается отлично, но когда я пытаюсь получить доступ к wsdl через консоль администратора Glasssfish. Это дает мне следующую ошибку.java struts2 hibernate and spring application and soap web services

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> 
+0

Какой URL-адрес вы вводите в браузере, который не может отображать действие в вашей конфигурации? –

+1

@RomanC в стеклянной доске консоль администратора это ссылка http: // localhost: 8080/ossoc/UsersControllerImplService? Wsdl – user3108790

ответ

2

Почему все здесь так хочется, чтобы провалить.

В этом была проблема. В web.xml фильтр struts2 имеет /* url pattern, так что struts2 будет фильтровать каждый запрос, который приходит на него, включая запрос сервлета webservice. Поскольку фильтры выполняются перед сервлетами, я получаю действие, которое не отображает ошибку. Из документации struts2. Расширение отображения действия было изменено на .action plus «", это означает, что если я просто введите имя сервлета в адресной строке, struts2 примет его как действие и проверит struts2.xml для соответствующего сопоставления действий, так как нет никакого сопоставления действий, поэтому это вызовет ошибку.

Решения Я просто добавить .extension после URL в отображении шаблона URL так struts2 будет рассматривать в качестве запроса сервлета другого варианта будет использовать

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

Надеется, что это помогает другим.