cxf2.0.4 + spring2.0.8 + tomcat 5.5 开发环境
服务程序代码就省略了,下面是配置.
启动TOMCAT后服务正常启动JSP 也可以正常运行.
调用http://localhost:8080/EMSTest/DictionaryType的地址时候服务器找不到SERVER
,大家看看是什么原因造成的,是TOMCAT版本有问题吗?
警告: Can't find the the request for http://localhost:8080/EMSTest/DictionaryType's Observer
web.xml
<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>/*</url-pattern>
</servlet-mapping>
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="dictionary" class="com.gdcn.bpaf.service.impl.DictionaryTypeServiceImpl" />
<jaxws:endpoint id="dictionaryType" implementor="#dictionary" address="/DictionaryType" />
<bean id="catalog" class="com.gdcn.bpaf.service.impl.SysCatalogServiceImpl" />
<jaxws:endpoint id="sysCatalog" implementor="#catalog" address="/SysCatalog" />
<bean id="serialNo" class="com.gdcn.bpaf.service.impl.SysSerialNoServiceImpl" />
<jaxws:endpoint id="sysSerialNo" implementor="#serialNo" address="/SysSerialNo" />
</beans>
client.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- START SNIPPET: beans -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
<bean id="client" class="com.gdcn.bpaf.service.IDictionaryTypeService"
factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.gdcn.bpaf.service.IDictionaryTypeService"/>
<property name="address" value="http://localhost:8080/EMSTest/DictionaryType"/>
</bean>
</beans>
<!-- END SNIPPET: beans -->
客户端调用代码,SWT的桌面客户端调用
public class testUI {
protected Shell shell;
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
try {
testUI window = new testUI();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window
* @throws Exception
*/
public void open() throws Exception {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
/**
* Create contents of the window
* @throws Exception
*/
protected void createContents() throws Exception {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
final Label label = new Label(shell, SWT.NONE);
label.setText(testServiceMethod());
label.setBounds(132, 98, 213, 73);
//
}
public String testServiceMethod() throws Exception {
// START SNIPPET: client
ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(new String[] {"com/ems/test/client-beans.xml"});
com.gdcn.bpaf.service.IDictionaryTypeService client = (IDictionaryTypeService)context.getBean("client");
com.gdcn.bpaf.model.BPAFDictionaryType response = client.getDictionaryTypeByCode("test");
System.out.println("Response: " + response.getDictionary_name());
return response.getDictionary_name();
// END SNIPPET: client
}
}
分享到:
- 2008-03-19 18:26
- 浏览 1843
- 评论(0)
- 论坛回复 / 浏览 (0 / 1790)
- 查看更多
相关推荐
在这个例子中,推荐使用CXF 2.0.4,因为它兼容JDK 1.5。下载后,将lib目录下的所有jar包添加到项目类路径中。 接下来是配置步骤。在`web.xml`中,我们需要添加CXF的Servlet配置,定义名为`cxf`的Servlet,并设置`...
【CXF Webservice初学笔记】 Apache CXF 是一个开源框架,主要用于构建和开发Web服务。这个框架提供了全面的支持,包括SOAP、RESTful、JSON、WS-*标准等,使得开发者可以方便地创建和消费Web服务。这篇初学笔记将...
cxf与spring集成 需要最少的jar如下: cxf-2.3.3.jar geronimo-annotation_1.0_spec-1.1.1.jar geronimo-jaxws_2.2_spec-1.0.jar geronimo-stax-api_1.0_spec-1.0.1.jar geronimo-ws-metadata_2.0_spec-1.1.3.jar ...
8. **neethi-2.0.4.jar**:Neethi是Apache的政策框架,用于处理Web服务政策表达语言(WSDL Policy)和SOAP绑定策略,帮助CXF处理服务安全和互操作性问题。 9. **geronimo-stax-api_1.0_spec-1.0.1.jar**:Apache ...
WebService所需的Jar包