spring httpinvoker客户端找不到服务URL [英] spring httpinvoker client can not find the service url

查看:212
本文介绍了spring httpinvoker客户端找不到服务URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Web应用程序具有以下配置.

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>

我在 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日志中,我追踪到那个春天对http://{host}/remote/domain/provision.htm进行了POST调用.

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.

问题:

  1. 我需要为httpInvoker位创建一个单独的应用程序上下文吗?我的意思是,我已经拥有一个可以处理正常Web操作的Web上下文.我需要在web.xml中为httpInvoker工具声明{another-context}并具有服务配置.在{another-context} -servlet.xml中定义?

  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?

如果不是1,我的配置有什么问题?

If not 1, what is wrong in my configuration?

推荐答案

知道了.上面的问题1附带了答案.我需要为http调用功能创建单独的Web上下文.

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.

这是因为,在我的普通webapp上下文(邮箱)中,我已经定义了SimpleUrlHandlerMapping,它将适当的URL映射到控制器.在那里找不到我要定义的http-invoker-serivce的地方.当我分离Web上下文时,它就像一个魅力! :D

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

祝您编程愉快! :)

这篇关于spring httpinvoker客户端找不到服务URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆