Web services 为什么我要使用JBossAS7在两个不同的地址发布Web服务?

Web services 为什么我要使用JBossAS7在两个不同的地址发布Web服务?,web-services,jboss,cxf,jboss7.x,jbossws,Web Services,Jboss,Cxf,Jboss7.x,Jbossws,作为了解JAX-WS和CXF的练习,我决定实现一个计算BMI的小型服务。 它是基于 我假设只使用我在xml端点定义中指定的地址,但实际上jboss也使它在其他地方可用 我在两家公司都能得到同样的服务 http://localhost:8080/BMI/BmiCalculatorService 在 http://localhost:8080/BMI/services/cxfBmi. 有人能帮忙吗 这是我的web.xml: <web-app> <context-param&g

作为了解JAX-WS和CXF的练习,我决定实现一个计算BMI的小型服务。 它是基于

我假设只使用我在xml端点定义中指定的地址,但实际上jboss也使它在其他地方可用

我在两家公司都能得到同样的服务

http://localhost:8080/BMI/BmiCalculatorService 

http://localhost:8080/BMI/services/cxfBmi.
有人能帮忙吗

这是我的web.xml:

<web-app>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/beans.xml</param-value>
</context-param>

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

<servlet>
    <servlet-name>CXFServlet</servlet-name>
    <display-name>CXF Servlet</display-name>
    <servlet-class>
        org.apache.cxf.transport.servlet.CXFServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
以及服务的实施:

package com.company.bmi.services;

import javax.jws.WebService;


@WebService(endpointInterface="com.company.bmi.services.BMICalculator", serviceName="BmiCalculatorService") 
public class BMICalculatorImpl implements BMICalculator {

    @Override
    public double computeBMI(double weight, double height) {
        return weight / (height * height);
    }

}
在Jboss的日志中,我看到我提到的第一个URL实际上是设置为服务的发布地址的URL。然后将其更改为我在xml文件中指定的。问题是第一个地址仍然有效,这在我看来是不正确的

但是稍后在日志中,服务器还抱怨找不到服务的观察者,所以我想知道这是否是导致不良结果的原因

以下是日志示例:

10:29:39,326 INFO  [org.jboss.wsf.stack.cxf.metadata.MetadataBuilder] (MSC service thread 1-5) Add Service
id=com.company.bmi.services.BMICalculatorImpl
address=http://localhost:8080/BMI/BmiCalculatorService
implementor=com.company.bmi.services.BMICalculatorImpl
invoker=org.jboss.wsf.stack.cxf.JBossWSInvoker
serviceName={http://services.bmi.company.com/}BmiCalculatorService
portName={http://services.bmi.company.com/}BMICalculatorImplPort
wsdlLocation=null
mtomEnabled=false
10:29:39,441 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-5) Creating Service {http://services.bmi.company.com/}BmiCalculatorService from class com.company.bmi.services.BMICalculator
10:29:39,748 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-5) Setting the server's publish address to be http://localhost:8080/BMI/BmiCalculatorService
10:29:39,832 INFO  [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-5) WSDL published to: file:/zimory/jboss/switchyard-as7-0.5/standalone/data/wsdl/BMICalculator-0.0.1-SNAPSHOT.war/BmiCalculatorService.wsdl
10:29:39,836 INFO  [org.jboss.as.webservices] (MSC service thread 1-2) JBAS015539: Starting service jboss.ws.port-component-link
10:29:39,844 INFO  [org.jboss.as.webservices] (MSC service thread 1-4) JBAS015539: Starting service jboss.ws.endpoint."BMICalculator-0.0.1-SNAPSHOT.war"."com.company.bmi.services.BMICalculatorImpl"
10:29:39,847 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-4) register: jboss.ws:context=BMI,endpoint=com.company.bmi.services.BMICalculatorImpl
10:29:39,849 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016008: Starting weld service for deployment BMICalculator-0.0.1-SNAPSHOT.war
10:29:40,077 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/BMI]] (MSC service thread 1-5) Initializing Spring root WebApplicationContext
10:29:40,078 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Root WebApplicationContext: initialization started
10:29:40,091 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-5) Refreshing Root WebApplicationContext: startup date [Fri Mar 15      10:29:40 CET 2013]; root of context hierarchy
10:29:40,111 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from ServletContext resource [/WEB-INF/beans.xml]
10:29:40,138 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
10:29:40,152 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
10:29:40,162 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
10:29:40,415 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-5) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7cbdc6a3: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,calcBMI]; root of factory hierarchy
10:29:40,498 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-5) Creating Service {http://services.bmi.company.com/}BmiCalculatorService from class com.company.bmi.services.BMICalculator
10:29:40,724 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-5) Setting the server's publish address to be /cxfBmi
10:29:40,730 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Root WebApplicationContext: initialization completed in 652 ms
10:29:40,763 INFO  [org.jboss.web] (MSC service thread 1-5) JBAS018210: Registering web context: /BMI
10:29:40,874 INFO  [org.jboss.as.server] (management-handler-thread - 2) JBAS018559: Deployed "BMICalculator-0.0.1-SNAPSHOT.war" [2013-03-15 10:29:40,895] Artifact BMICalculator:war: Artifact is deployed successfully
10:39:07,639 WARNING [org.apache.cxf.transport.servlet.ServletController] (http--127.0.0.1-8080-2) Can't find the the request for http://localhost:8080/BMI/services/cfxBmi/BmiCalculatorService's Observer

地址
http://localhost:8080/BMI/services/*
由explicit
CXFServlet
创建

http://localhost:8080/BMI/BmiCalculatorService
由org.jboss.wsf.stack.cxf.metadata.MetadataBuilder通过隐式注释扫描创建


请参阅治疗。

地址
http://localhost:8080/BMI/services/*
由explicit
CXFServlet
创建

http://localhost:8080/BMI/BmiCalculatorService
由org.jboss.wsf.stack.cxf.metadata.MetadataBuilder通过隐式注释扫描创建


请参阅以获取解决方法。

好的,因此关于观察者的警告不再存在,并且服务仍然在相同的两个不同地址可用,这意味着此观察者问题与问题根本没有关系。好的,因此关于观察者的警告不再存在,而且服务仍然可以在相同的两个不同的地址使用,这意味着这个观察员问题根本与问题无关。嗨!首先非常感谢:)这正是我需要的:)嗨!首先非常感谢:)这正是我需要的:)
package com.company.bmi.services;

import javax.jws.WebService;


@WebService(endpointInterface="com.company.bmi.services.BMICalculator", serviceName="BmiCalculatorService") 
public class BMICalculatorImpl implements BMICalculator {

    @Override
    public double computeBMI(double weight, double height) {
        return weight / (height * height);
    }

}
10:29:39,326 INFO  [org.jboss.wsf.stack.cxf.metadata.MetadataBuilder] (MSC service thread 1-5) Add Service
id=com.company.bmi.services.BMICalculatorImpl
address=http://localhost:8080/BMI/BmiCalculatorService
implementor=com.company.bmi.services.BMICalculatorImpl
invoker=org.jboss.wsf.stack.cxf.JBossWSInvoker
serviceName={http://services.bmi.company.com/}BmiCalculatorService
portName={http://services.bmi.company.com/}BMICalculatorImplPort
wsdlLocation=null
mtomEnabled=false
10:29:39,441 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-5) Creating Service {http://services.bmi.company.com/}BmiCalculatorService from class com.company.bmi.services.BMICalculator
10:29:39,748 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-5) Setting the server's publish address to be http://localhost:8080/BMI/BmiCalculatorService
10:29:39,832 INFO  [org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher] (MSC service thread 1-5) WSDL published to: file:/zimory/jboss/switchyard-as7-0.5/standalone/data/wsdl/BMICalculator-0.0.1-SNAPSHOT.war/BmiCalculatorService.wsdl
10:29:39,836 INFO  [org.jboss.as.webservices] (MSC service thread 1-2) JBAS015539: Starting service jboss.ws.port-component-link
10:29:39,844 INFO  [org.jboss.as.webservices] (MSC service thread 1-4) JBAS015539: Starting service jboss.ws.endpoint."BMICalculator-0.0.1-SNAPSHOT.war"."com.company.bmi.services.BMICalculatorImpl"
10:29:39,847 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-4) register: jboss.ws:context=BMI,endpoint=com.company.bmi.services.BMICalculatorImpl
10:29:39,849 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016008: Starting weld service for deployment BMICalculator-0.0.1-SNAPSHOT.war
10:29:40,077 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/BMI]] (MSC service thread 1-5) Initializing Spring root WebApplicationContext
10:29:40,078 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Root WebApplicationContext: initialization started
10:29:40,091 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-5) Refreshing Root WebApplicationContext: startup date [Fri Mar 15      10:29:40 CET 2013]; root of context hierarchy
10:29:40,111 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from ServletContext resource [/WEB-INF/beans.xml]
10:29:40,138 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
10:29:40,152 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
10:29:40,162 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-5) Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
10:29:40,415 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-5) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7cbdc6a3: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,calcBMI]; root of factory hierarchy
10:29:40,498 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-5) Creating Service {http://services.bmi.company.com/}BmiCalculatorService from class com.company.bmi.services.BMICalculator
10:29:40,724 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-5) Setting the server's publish address to be /cxfBmi
10:29:40,730 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Root WebApplicationContext: initialization completed in 652 ms
10:29:40,763 INFO  [org.jboss.web] (MSC service thread 1-5) JBAS018210: Registering web context: /BMI
10:29:40,874 INFO  [org.jboss.as.server] (management-handler-thread - 2) JBAS018559: Deployed "BMICalculator-0.0.1-SNAPSHOT.war" [2013-03-15 10:29:40,895] Artifact BMICalculator:war: Artifact is deployed successfully
10:39:07,639 WARNING [org.apache.cxf.transport.servlet.ServletController] (http--127.0.0.1-8080-2) Can't find the the request for http://localhost:8080/BMI/services/cfxBmi/BmiCalculatorService's Observer