在cxf官网提供的例子中,直接运行main方法就可以发布运行cxf的webservice服务了。而无需借助tomcat这是为什么呢?
其实CXF 内置了 Jetty(Servlet 容器),因此你不需要将你的程序部署到 Tomcat 等 Web 服务器也可以正常发布web服务。
WSDL文件构成:
详见:http://www.w3school.com.cn/wsdl/index.asp
假设我们发布一个简单服务。现在看一下控制台中的输出信息:
2009-6-17 22:35:57 org.apache.cxf.interceptor.LoggingInInterceptor logging 信息: Inbound Message ---------------------------- ID: 2 Address: /helloService Encoding: UTF-8 Content-Type: text/xml; charset=UTF-8 Headers: {content-type=[text/xml; charset=UTF-8], connection=[keep-alive], Host=[127.0.0.1:8080], Content-Length=[367], SOAPAction=[""], User-Agent=[Apache CXF 2.2.2], Content-Type=[text/xml; charset=UTF-8], Accept=[*/*], Pragma=[no-cache], Cache-Control=[no-cache]} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns 2:selectMaxAgeStudent xmlns:ns2="http://server.soap.ilkj.net/"><c1><birthday>1989-01-28T00: 00:00.000+08:00</birthday><id>1</id><name>A</name></c1><c2><birthday> 1990-01-28T00:00:00.000+08:00</birthday><id>2</id><name>B</name></c2> </ns2:selectMaxAgeStudent></soap:Body></soap:Envelope> -------------------------------------- 2009-6-17 22:35:57 org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose 信息: Outbound Message --------------------------- ID: 2 Encoding: UTF-8 Content-Type: text/xml Headers: {} Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns 2:selectMaxAgeStudentResponse xmlns:ns2="http://server.soap.ilkj.net/"><return><birthday>1989-01-28 T00:00:00+08:00</birthday><id>1</id><name>A</name></return></ns2:sele ctMaxAgeStudentResponse></soap:Body></soap:Envelope> --------------------------------------
Inbound Message输出的是服务器端接收到的 SOAP 信息,
Outbound Message输出的服务器端响应的 SOAP 信息,
SOAP 的 Headers:{}的前面是 SOAP 消息的标识、编码方式、MIME类型,
Headers:{}熟悉 HTTP 应该很容易看懂这里面的消息报头的作用,
Headers:{}后面的Payload(有效负载,也叫净荷)的 XML 就是 SOAP 消息的真正内容,
我们看到 SOAP 消息内容被封装为<soap:Envelope …SOAP 信封,在信封之间的内容就是 SOAP 消息正文,这
个元素还有一个子元素<soap:Header …,如果你的某些注解的 header=true,那么它将被放到
<soap:Header …中传输,而不是 SOAP 消息正文。