spring httpinvoker客户端找不到服务url

发布于 2024-11-29 23:26:20 字数 2307 浏览 0 评论 0原文

我对网络应用程序有以下配置。

web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:mail-application-context.xml
....
    </context-param>
....
<servlet> 
<servlet-name>mailbox</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>mailbox</servlet-name>
        <url-pattern>*.htm</url-pattern>
</servlet-mapping>

mailbox-servlet.xml

    <bean name="remoteProvisioningServiceImpl" class="pw.domain.service.RemoteProvisioningServiceImpl"/>

<bean name="/remote/domain/provision.htm" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    <property name="service" ref="remoteProvisioningServiceImpl" />
    <property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean>

我已经在 mail-application-context.xml 中正确配置了客户端,如下所示

    <bean id="remoteProvisioningService1" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://${mailapp.dc.host.1.url}/remote/domain/provision.htm" />
    <property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean> 

<bean id="remoteProvisioningService2" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://${mailapp.dc.host.2.url}/remote/domain/provision.htm" />
    <property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean> 

。 .. 问题。 在适当的事件中,客户端通过 httpinvoker 工具正确调用服务,但响应是 http-404。在 nginx 日志中,我跟踪 spring 对 http://{host}/remote/domain/provision.htm 进行了 POST 调用。

问题:

  1. 我需要为 httpInvoker 位创建单独的应用程序上下文吗?我的意思是,我已经有了一个网络上下文来处理正常的网络操作。我是否需要在 web.xml 中为 httpInvoker 设施声明 {another-context} 并进行服务配置。在 {another-context}-servlet.xml 中定义?

  2. 如果不是 1,我的配置出了什么问题?

I have following configuration for the web application.

web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:mail-application-context.xml
....
    </context-param>
....
<servlet> 
<servlet-name>mailbox</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>mailbox</servlet-name>
        <url-pattern>*.htm</url-pattern>
</servlet-mapping>

mailbox-servlet.xml

    <bean name="remoteProvisioningServiceImpl" class="pw.domain.service.RemoteProvisioningServiceImpl"/>

<bean name="/remote/domain/provision.htm" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    <property name="service" ref="remoteProvisioningServiceImpl" />
    <property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean>

I have the clients configured properly, like following, in mail-application-context.xml

    <bean id="remoteProvisioningService1" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://${mailapp.dc.host.1.url}/remote/domain/provision.htm" />
    <property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean> 

<bean id="remoteProvisioningService2" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://${mailapp.dc.host.2.url}/remote/domain/provision.htm" />
    <property name="serviceInterface" value="pw.domain.service.RemoteProvisioningService" />
</bean> 

And now... the problem.
On an appropriate event, the clients rightly call service through httpinvoker facility but the response is http-404. In nginx logs, i trace that spring makes a POST call to http://{host}/remote/domain/provision.htm.

Questions :

  1. Do i need to create a separate app-context for httpInvoker bit? i mean, i already have one web context to deal with normal web operations. Do i need to declare {another-context} in web.xml for httpInvoker facility and having the service config. defined in {another-context}-servlet.xml?

  2. If not 1, what is wrong in my configuration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命硬 2024-12-06 23:26:20

明白了..上面的问题 1 已附有答案。我需要为 http 调用工具创建一个单独的 Web 上下文才能工作。

这是因为,在我正常的 web 应用程序上下文(邮箱)中,我已经定义了 SimpleUrlHandlerMapping ,它将适当的 url 映射到控制器。在那里它找不到我想要定义的 http-invoker-serivce 的位置。当我分离网络上下文时,它就像一个魅力! :D

编码愉快! :)

Got it.. Question 1 above has the answer attached to it. I need to create a separate web context for http-invoking facility to work.

This is because, in my normal webapp context (mailbox), i already have defined SimpleUrlHandlerMapping which maps appropriate urls to controllers. There it doesnt find place for http-invoker-serivce i want to define. When i separated web contexts, it worked like a charm! :D

Happy coding! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文