?
?
?
参考:https://www6.software.ibm.com/developerworks/cn/education/java/j-cxf/index.html
?
?
?
wsdl的描述:
-
-
-
??<?xml?version="1.0"?encoding="UTF-8"??>?
-
-?<wsdl:definitions?name="ISurveyServiceService"?targetNamespace="http://cxf.ws/"?xmlns:ns1="http://cxf.apache.org/bindings/xformat"?xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"?xmlns:tns="http://cxf.ws/"?xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"?xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
-?<wsdl:types>
-
-?<xs:schema?attributeFormDefault="unqualified"?elementFormDefault="unqualified"?targetNamespace="http://cxf.ws/"?xmlns:tns="http://cxf.ws/"?xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
??<xs:element?name="vote"?type="tns:vote"?/>?
-
??<xs:element?name="voteResponse"?type="tns:voteResponse"?/>?
-
-?<xs:complexType?name="vote">
-
-?<xs:sequence>
-
??<xs:element?minOccurs="0"?name="arg0"?type="xs:string"?/>?
-
??<xs:element?name="arg1"?type="xs:int"?/>?
-
??</xs:sequence>
-
??</xs:complexType>
-
-?<xs:complexType?name="voteResponse">
-
-?<xs:sequence>
-
??<xs:element?minOccurs="0"?name="return"?type="xs:string"?/>?
-
??</xs:sequence>
-
??</xs:complexType>
-
??</xs:schema>
-
??</wsdl:types>
-
-?<wsdl:message?name="vote">
-
??<wsdl:part?element="tns:vote"?name="parameters"?/>?
-
??</wsdl:message>
-
-?<wsdl:message?name="voteResponse">
-
??<wsdl:part?element="tns:voteResponse"?name="parameters"?/>?
-
??</wsdl:message>
-
-?<wsdl:portType?name="ISurveyService">
-
-?<wsdl:operation?name="vote">
-
??<wsdl:input?message="tns:vote"?name="vote"?/>?
-
??<wsdl:output?message="tns:voteResponse"?name="voteResponse"?/>?
-
??</wsdl:operation>
-
??</wsdl:portType>
-
-?<wsdl:binding?name="ISurveyServiceServiceSoapBinding"?type="tns:ISurveyService">
-
??<soap:binding?style="document"?transport="http://schemas.xmlsoap.org/soap/http"?/>?
-
-?<wsdl:operation?name="vote">
-
??<soap:operation?soapAction=""?style="document"?/>?
-
-?<wsdl:input?name="vote">
-
??<soap:body?use="literal"?/>?
-
??</wsdl:input>
-
-?<wsdl:output?name="voteResponse">
-
??<soap:body?use="literal"?/>?
-
??</wsdl:output>
-
??</wsdl:operation>
-
??</wsdl:binding>
-
-?<wsdl:service?name="ISurveyServiceService">
-
-?<wsdl:port?binding="tns:ISurveyServiceServiceSoapBinding"?name="ISurveyServicePort">
-
??<soap:address?location="http://localhost:8080/CXF_Spring_Survey//SurveyWebService"?/>?
-
??</wsdl:port>
-
??</wsdl:service>
-
??</wsdl:definitions>
客户端测试:
-
? import?org.springframework.context.ApplicationContext;
- import?org.springframework.context.support.ClassPathXmlApplicationContext;
- import?ws.cxf.ISurveyService;
-
public?class?Test?{
-
????public?static?void?main(String[]?args)?{
-
????????System.out.println("test");
-
????????
-
????????ApplicationContext?context?=?new?ClassPathXmlApplicationContext("beanRefClient.xml");
-
????????
-
????????ISurveyService?surveyService?=?(ISurveyService)context.getBean("surveyServiceClient");
-
????????
-
????????String?username?=?"Test";
-
????????int?point?=?88;
-
????????
- ????????String?result?=?surveyService.vote(username,point);
-
????????System.out.println("Result:"?+?result);
-
????????
-
????????username?=?"Michael";
- ????????point?=?100;
-
????????
- ????????result?=?surveyService.vote(username,point);
-
????????System.out.println("Result:"?+?result);
-
????????
-
????????username?=?"Jordan";
- ????????point?=?9;
- ????????result?=?surveyService.vote(username,point);
-
????????System.out.println("Result:"?+?result);
- ????}
- }
test
- 2008-11-16?23:04:26?org.springframework.context.support.AbstractApplicationContext?prepareRefresh
- 信息:?Refreshing?org.springframework.context.support.ClassPathXmlApplicationContext@1484a05:?display?name?[org.springframework.context.support.ClassPathXmlApplicationContext@1484a05];?startup?date?[Sun?Nov?16?23:04:26?CST?2008];?root?of?context?hierarchy
- 2008-11-16?23:04:26?org.springframework.beans.factory.xml.XmlBeanDefinitionReader?loadBeanDefinitions
-
信息:?Loading?XML?bean?definitions?from?class?path?resource?[beanRefClient.xml]
- 2008-11-16?23:04:26?org.springframework.beans.factory.xml.XmlBeanDefinitionReader?loadBeanDefinitions
-
信息:?Loading?XML?bean?definitions?from?class?path?resource?[META-INF/cxf/cxf.xml]
- 2008-11-16?23:04:26?org.springframework.beans.factory.xml.XmlBeanDefinitionReader?loadBeanDefinitions
-
信息:?Loading?XML?bean?definitions?from?class?path?resource?[META-INF/cxf/cxf-extension-soap.xml]
- 2008-11-16?23:04:27?org.springframework.beans.factory.xml.XmlBeanDefinitionReader?loadBeanDefinitions
-
信息:?Loading?XML?bean?definitions?from?class?path?resource?[META-INF/cxf/cxf-servlet.xml]
- 2008-11-16?23:04:27?org.springframework.context.support.AbstractApplicationContext?obtainFreshBeanFactory
-
信息:?Bean?factory?for?application?context?[org.springframework.context.support.ClassPathXmlApplicationContext@1484a05]:?org.springframework.beans.factory.support.DefaultListableBeanFactory@fb6c5f
- 2008-11-16?23:04:27?org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker?postProcessAfterInitialization
-
信息:?Bean?'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor'?is?not?eligible?for?getting?processed?by?all?BeanPostProcessors?(for?example:?not?eligible?for?auto-proxying)
- 2008-11-16?23:04:27?org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker?postProcessAfterInitialization
-
信息:?Bean?'org.apache.cxf.bus.spring.BusExtensionPostProcessor'?is?not?eligible?for?getting?processed?by?all?BeanPostProcessors?(for?example:?not?eligible?for?auto-proxying)
- 2008-11-16?23:04:27?org.springframework.beans.factory.support.DefaultListableBeanFactory?preInstantiateSingletons
-
信息:?Pre-instantiating?singletons?in?org.springframework.beans.factory.support.DefaultListableBeanFactory@fb6c5f:?defining?beans?[cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.servlet.ServletTransportFactory,surveyServiceClient.proxyFactory,surveyServiceClient];?root?of?factory?hierarchy
- Result:谢谢你的投票!你的投票分数通过审核!
- Result:你不能重复进行投票!
- Result:谢谢你的投票!你的投票分数太低!
?
开发过程中如果出现如下错误:
页面报错: java.lang.NoSuchMethodError: org.w3c.dom.Document.setXmlStandalone(Z)V org.apache.cxf.transport.http.WSDLQueryHandler.updateDoc(WSDLQueryHandler.java:253) org.apache.cxf.transport.http.WSDLQueryHandler.writeResponse(WSDLQueryHandler.java:201) org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152) org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:174) org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:156) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
?
考虑换掉tomcat版本即可。
?
IBM提供的下载地址:https://www6.software.ibm.com/developerworks/cn/education/java/j-cxf/CXF_Spring_Survey_Src.war
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|