cxf 实现soap binding的问题

64 views
Skip to first unread message

blue

unread,
Jan 15, 2013, 7:58:21 AM1/15/13
to cxf...@googlegroups.com
我在学习用CXF写SOAP service,我想实现的功能是根据不同的soap body自动binding不同的method。
比如说, 根据wsdl定义产生对
MessageA请求
。。。。。
<SOAP-ENV:Body>
     <MessageA>
      。。。。。。。。。
     〈/MessageA〉
。。。。。。
的handleMessageA(SOAPMessage msga) method。 对MessageB产生handleMessageB()method, 以此类推。             
然后SOAP message进来的时候,自动调用相应的handle。

我用了cxf wsdl_first_soap12的例子(http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/wsdl_first_soap12/),但是改了pom.xml后。编译报错

xecution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.7.1:wsdl2java failed: 
 Summary:  Failures: 10, Warnings: 0

 <<< ERROR! 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[142,4] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[141,13] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[126,13] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[125,13] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[147,4] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[146,13] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[152,4] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[151,13] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[137,4] 
file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[136,13] 

 (org.apache.cxf:cxf-codegen-plugin:2.7.1:wsdl2java:generate-sources:generate-sources)

我的pom.xml是这样的
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xinjie.rps.lbs</groupId>
  <artifactId>LBS</artifactId>
  <version>1.0</version>
  <name>Maven Java RPS LoadBalanceRouter</name>
  <description>Maven Java RPS LoadBalanceRouter</description>
  <properties>
  <cxf.version>2.7.1</cxf.version>
  <spring-version>3.0.5.RELEASE</spring-version>
  </properties>
  <dependencies>
  
  <!--  Apache CXF dependency -->
  <dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-rt-frontend-jaxws</artifactId>
   <version>${cxf.version}</version>
  </dependency>
  <dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-rt-transports-http</artifactId>
   <version>${cxf.version}</version>
  </dependency>
    <dependency>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-rt-transports-http-jetty</artifactId>
   <version>${cxf.version}</version>
  </dependency>
  <!--  Spring dependency -->
  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring-version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring-version}</version>
    </dependency>
  </dependencies>
  <build>
  <plugins>
   <plugin>
     <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
   </plugin>
   <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>${cxf.version}</version>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
              <wsdlOptions>
                <wsdlOption>
                  <frontEnd>jaxws21</frontEnd>
                  <faultSerialVersionUID>1</faultSerialVersionUID>
                  <wsdl>${basedir}/src/main/resources/wsdl/hello_world_soap12.wsdl</wsdl>
                </wsdlOption>
              </wsdlOptions>
            </configuration>
            <goals>
              <goal>wsdl2java</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
  </plugins>
  </build>
  <profiles>
    <profile>
      <id>server</id>
      <build>
        <defaultGoal>test</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>test</phase>
            <goals>
                  <goal>java</goal>
                </goals>
                <configuration>
                  <mainClass>demo.hw.server.Server</mainClass>
                  <arguments>
                    <argument>${basedir}/src/main/resources/wsdl/hello_world_soap12.wsdl</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>client</id>
      <build>
        <defaultGoal>test</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>test</phase>
                <goals>
                  <goal>java</goal>
                </goals>
                <configuration>
                  <mainClass>demo.hw.client.Client</mainClass>
                  <arguments>
                    <argument>${basedir}/src/main/resources/wsdl/hello_world_soap12.wsdl</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>client.get</id>
      <build>
        <defaultGoal>test</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
              <executions>
                <execution>
                  <phase>test</phase>
                  <goals>
                    <goal>java</goal>
                  </goals>
                  <configuration>
                    <mainClass>demo.hw.client.Get</mainClass>
                    <arguments>
                      <argument>${basedir}/wsdl/hello_world_soap12.wsdl</argument>
                    </arguments>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>
      </profile>
    </profiles>
</project>

而且没有生成相应的Java代码。 我用的IDE是Eclipse Juno。请问是什么问题? 谢谢。

blue

unread,
Jan 16, 2013, 7:56:23 AM1/16/13
to cxf...@googlegroups.com
忘了wsdl文件,现在加上。
############################################################################


<?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
 
 
  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.
-->

<definitions name="LoadBalanceRouter"
    <wsdl:types>
elementFormDefault="qualified">
   <element name="ClientHeartBeat">
<complexType/>
</element>
   <element name="ClientHeartBeatResponse">
<complexType/>
   </element>
<element name="ServiceHeartBeat">
<complexType/>
   </element>
   <element name="ServiceHeartBeatResponse">
<complexType/>
   </element>
<element name="RegisterClient">
<complexType/>
</element>
   <element name="RegisterClientResponse">
<complexType/>
   </element>
<element name="RegisterService">
<complexType/>
   </element>
   <element name="RegisterServiceResponse">
<complexType/>
   </element>
<element name="ValueProducts">
<complexType/>
   </element>
   <element name="ValueProductsResponse">
<complexType/>
   </element>
<element name="UnsubscribeProducts">
<complexType/>
   </element>
   <element name="UnsubscribeProductsResponse">
<complexType/>
   </element>
<element name="ReloadProducts">
<complexType/>
   </element>
   <element name="ReloadProductsResponse">
<complexType/>
   </element>
<element name="ReloadInputs">
<complexType/>
   </element>
   <element name="ReloadInputsResponse">
<complexType/>
   </element>

   <element name="faultDetail">
<complexType>
<sequence>
<element name="host" type="string"/>
<element name="instance" type="short"/>
</sequence>
            </complexType>
   </element>
        </schema>
    </wsdl:types>

    <wsdl:message name="ServiceHeartBeatRequest">
        <wsdl:part name="in" element="x1:ServiceHeartBeat"/>
    </wsdl:message>
    <wsdl:message name="ServiceHeartBeatResponse">
        <wsdl:part name="out" element="x1:ServiceHeartBeatResponse"/>
    </wsdl:message>
<wsdl:message name="ClientHeartBeatRequest">
        <wsdl:part name="in" element="x1:ClientHeartBeat"/>
    </wsdl:message>
    <wsdl:message name="ClientHeartBeatResponse">
        <wsdl:part name="out" element="x1:ClientHeartBeatResponse"/>
    </wsdl:message>
<wsdl:message name="RegisterClientRequest">
        <wsdl:part name="in" element="x1:RegisterClient"/>
    </wsdl:message>
    <wsdl:message name="RegisterClientResponse">
        <wsdl:part name="out" element="x1:RegisterClientResponse"/>
    </wsdl:message>
<wsdl:message name="RegisterServerRequest">
        <wsdl:part name="in" element="x1:RegisterServer"/>
    </wsdl:message>
    <wsdl:message name="RegisterServerResponse">
        <wsdl:part name="out" element="x1:RegisterServerResponse"/>
    </wsdl:message>
    <wsdl:message name="MessageFault">
<wsdl:part name="faultDetail" element="x1:faultDetail"/>
    </wsdl:message>

    <wsdl:portType name="LoadBalanceRouter">
        <wsdl:operation name="ServerHeartBeat">
            <wsdl:input name="ServerHeartBeatRequest" message="tns:ServerHeartBeatRequest"/>
            <wsdl:output name="ServerHeartBeatResponse" message="tns:ServerHeartBeatResponse"/>
<wsdl:fault name="MessageFault" message="tns:MessageFault"/>
        </wsdl:operation>
        <wsdl:operation name="ClientHeartBeat">
            <wsdl:input message="tns:ClientHeartBeatRequest" name="ClientHeartBeatRequest"/>
            <wsdl:output message="tns:ClientHeartBeatResponse" name="ClientHeartBeatResponse"/>
<wsdl:fault name="MessageFault" message="tns:MessageFault"/>
        </wsdl:operation>
        
        <wsdl:operation name="ValueProducts">
            <wsdl:input message="tns:ValueProductsRequest" name="ValueProductsRequest"/>
<wsdl:output message="tns:ValueProductsResponse" name="ValueProductsResponse"/>
<wsdl:fault name="MessageFault" message="tns:MessageFault"/>
        </wsdl:operation>
<wsdl:operation name="ReloadProducts">
            <wsdl:input message="tns:ReloadProductsRequest" name="ReloadProductsRequest"/>
<wsdl:output message="tns:ReloadProductsResponse" name="ReloadProductsResponse"/>
<wsdl:fault name="MessageFault" message="tns:MessageFault"/>
        </wsdl:operation>
<wsdl:operation name="ReloadInputs">
            <wsdl:input message="tns:ReloadInputsRequest" name="ReloadInputsRequest"/>
<wsdl:output message="tns:ReloadInputsResponse" name="ReloadInputsResponse"/>
<wsdl:fault name="MessageFault" message="tns:MessageFault"/>
        </wsdl:operation>
<wsdl:operation name="UnsubscribeProducts">
            <wsdl:input message="tns:UnsubscribeProductsRequest" name="UnsubscribeProductsRequest"/>
<wsdl:output message="tns:UnsubscribeProductsResponse" name="UnsubscribeProductsResponse"/>
<wsdl:fault name="MessageFault" message="tns:MessageFault"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="LBS_SOAPBinding" type="tns:LoadBalanceRouter">
<soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" />
       <wsdl:operation name="ServerHeartBeat">
            <soap12:operation soapAction="" style="document"/>
            <wsdl:input name="ServerHeartBeatRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="ServerHeartBeatResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="ClientHeartBeat">
            <soap12:operation soapAction="" style="document"/>
            <wsdl:input name="ClientHeartBeatRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="ClientHeartBeatResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
<wsdl:operation name="ValueProducts">
            <soap12:operation soapAction="" style="document"/>
            <wsdl:input name="ValueProductsRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="ValueProductsResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
<wsdl:operation name="ReloadProducts">
            <soap12:operation soapAction="" style="document"/>
            <wsdl:input name="ReloadProductsRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="ReloadProductsResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
<wsdl:operation name="ReloadInputs">
            <soap12:operation soapAction="" style="document"/>
            <wsdl:input name="ReloadInputsRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="ReloadInputsResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
<wsdl:operation name="UnsubscribeProducts">
            <soap12:operation soapAction="" style="document"/>
            <wsdl:input name="UnsubscribeProductsRequest">
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="UnsubscribeProductsResponse">
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>        
    </wsdl:binding>

    <wsdl:service name="SOAPService">
        <wsdl:port name="SoapPort" binding="tns:LBS_SOAPBinding">
            <soap12:address location="http://localhost:9000/SoapContext/SoapPort"/>
        </wsdl:port>
    </wsdl:service>
</definitions>

Freeman Fang

unread,
Jan 16, 2013, 11:03:47 PM1/16/13
to cxf...@googlegroups.com
Hi,

你的wsdl是invalid的, 缺少了很多message的定义
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat

--
您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com
要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com
更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
----
Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index

Jingbin Li

unread,
Jan 17, 2013, 8:51:02 AM1/17/13
to cxf...@googlegroups.com
Hi Freeman,

谢谢你的回复。

我在Wsdl里没有提供message的具体schema,是因为soap的格式根据product的不同,格式完全不一样,所以我需要在Java 代码里手动实现产品特有逻辑。不管什么信息,我想Wsdl产生的method总是bind SOAP body 的根节点, 这个能够实现吗?

也许我用的例子不适用这种情况。我想这是一个普遍的问题,就是Cxf如何实现Dynamic Schema soap 宾定?或者有其他的framework 能更好的实现? 谢谢


From my iPhone

Willem jiang

unread,
Jan 17, 2013, 9:11:42 AM1/17/13
to cxf...@googlegroups.com
你的WSDL是会变化的吗?还是在启动CXF的时候是WSDL是确定的?
如果这些都不能确定,那你需要通过比较底层的SOAP Message API来解决相关的逻辑调用问题。

JAXWS 支持 MessageProvider 和Dispatch 接口,通过这些接口可以很方便的实现对SOAP message的直接操作,你可以好好研究一下。

--
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem




On Thursday, January 17, 2013 at 9:51 PM, Jingbin Li wrote:

> Hi Freeman,
>
> 谢谢你的回复。
>
> 我在Wsdl里没有提供message的具体schema,是因为soap的格式根据product的不同,格式完全不一样,所以我需要在Java 代码里手动实现产品特有逻辑。不管什么信息,我想Wsdl产生的method总是bind SOAP body 的根节点, 这个能够实现吗?
>
> 也许我用的例子不适用这种情况。我想这是一个普遍的问题,就是Cxf如何实现Dynamic Schema soap 宾定?或者有其他的framework 能更好的实现? 谢谢
>
>
> From my iPhone
>
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadProductsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadProductsResponse%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[141,13]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadProductsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadProductsRequest%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[126,13]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ServerHeartBeatResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ServerHeartBeatResponse%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[125,13]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ServerHeartBeatRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ServerHeartBeatRequest%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[147,4]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadInputsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadInputsResponse%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[146,13]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadInputsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadInputsRequest%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[152,4]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:UnsubscribeProductsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:UnsubscribeProductsResponse%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[151,13]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:UnsubscribeProductsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:UnsubscribeProductsRequest%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[137,4]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ValueProductsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ValueProductsResponse%5D) not exist.
> > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[136,13]
> > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ValueProductsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ValueProductsRequest%5D) not exist.
> > > 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> > > 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)
> > > 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> > > ----
> > > Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
> >
> > --
> > 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> > 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> > 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)
> > 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> > ----
> > Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
>
>
> --
> 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)

Freeman Fang

unread,
Jan 18, 2013, 2:27:59 AM1/18/13
to cxf...@googlegroups.com
WSDL的本意就是用来准确描述接口的,你的WSDL不确定, 根本就不能用wsdl2java来动态生成code, wsdl2java本身要求一个valid的wsdl。
如果你的soap message是不定的, 也就是很难事先知道 object <=======> xml message, 你可以考虑 jaxws 的dispatch,provider, 就是在message层面直接操作, 不用wsdl

-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat

Jingbin Li

unread,
Jan 20, 2013, 8:26:25 PM1/20/13
to cxf...@googlegroups.com
Thank you for the reply. Sorry I could not type Chinese here.
I checked out jaxws dispatch/provider, seems they are the ones I am looking for. Though I still have one question, I see jaxws works with both CXF and Metro Frameworks. What is difference between the two? If I want to develop several services (not necessary web services), which communicate with each other through dynamic formatted SOAP over TCP, which one is better supported?

Thanks a lot. 


2013/1/18 Freeman Fang <freema...@gmail.com>

Willem jiang

unread,
Jan 20, 2013, 9:05:36 PM1/20/13
to cxf...@googlegroups.com
因为这个是中文讨论区,我还是用中文来回答你的问题吧。
第一,如果你用JAXWS Dispatch/Provider API来开发的话, 你的应用是应该可以部署在CXF 或者 Metro上面的。
CXF提供了SOAP over TCP,和SOAP over JMS的支持, Metro这部分的功能我不太清楚,你可以上网查一下。


--
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
On Monday, January 21, 2013 at 9:26 AM, Jingbin Li wrote:

> Thank you for the reply. Sorry I could not type Chinese here.
> I checked out jaxws dispatch/provider, seems they are the ones I am looking for. Though I still have one question, I see jaxws works with both CXF and Metro Frameworks. What is difference between the two? If I want to develop several services (not necessary web services), which communicate with each other through dynamic formatted SOAP over TCP, which one is better supported?
>
> Thanks a lot.
>
>
> 2013/1/18 Freeman Fang <freema...@gmail.com (mailto:freema...@gmail.com)>
> > WSDL的本意就是用来准确描述接口的,你的WSDL不确定, 根本就不能用wsdl2java来动态生成code, wsdl2java本身要求一个valid的wsdl。
> > 如果你的soap message是不定的, 也就是很难事先知道 object <=======> xml message, 你可以考虑 jaxws 的dispatch,provider, 就是在message层面直接操作, 不用wsdl
> >
> > -------------
> > Freeman(Yue) Fang
> >
> > Red Hat, Inc.
> > FuseSource is now part of Red Hat
> > Web: http://fusesource.com | http://www.redhat.com/
> > Twitter: freemanfang
> > Blog: http://freemanfang.blogspot.com
> > http://blog.sina.com.cn/u/1473905042
> > weibo: @Freeman小屋
> > On 2013-1-17, at 下午9:51, Jingbin Li wrote:
> > > Hi Freeman,
> > >
> > > 谢谢你的回复。
> > >
> > > 我在Wsdl里没有提供message的具体schema,是因为soap的格式根据product的不同,格式完全不一样,所以我需要在Java 代码里手动实现产品特有逻辑。不管什么信息,我想Wsdl产生的method总是bind SOAP body 的根节点, 这个能够实现吗?
> > >
> > > 也许我用的例子不适用这种情况。我想这是一个普遍的问题,就是Cxf如何实现Dynamic Schema soap 宾定?或者有其他的framework 能更好的实现? 谢谢
> > >
> > >
> > > From my iPhone
> > >
> > > 在 2013-1-16,23:03,Freeman Fang <freema...@gmail.com (mailto:freema...@gmail.com)> 写道:
> > >
> > > > Hi,
> > > >
> > > > 你的wsdl是invalid的, 缺少了很多message的定义
> > > > -------------
> > > > Freeman(Yue) Fang
> > > >
> > > > Red Hat, Inc.
> > > > FuseSource is now part of Red Hat
> > > > Web: http://fusesource.com (http://fusesource.com/) | http://www.redhat.com/
> > > > Twitter: freemanfang
> > > > Blog: http://freemanfang.blogspot.com (http://freemanfang.blogspot.com/)
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadProductsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadProductsResponse%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[141,13]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadProductsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadProductsRequest%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[126,13]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ServerHeartBeatResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ServerHeartBeatResponse%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[125,13]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ServerHeartBeatRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ServerHeartBeatRequest%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[147,4]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadInputsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadInputsResponse%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[146,13]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ReloadInputsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ReloadInputsRequest%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[152,4]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:UnsubscribeProductsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:UnsubscribeProductsResponse%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[151,13]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:UnsubscribeProductsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:UnsubscribeProductsRequest%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[137,4]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ValueProductsResponse] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ValueProductsResponse%5D) not exist.
> > > > > > file:/C:/MyProjects/JavaWorkSpace/LBS/src/main/resources/wsdl/hello_world_soap12.wsdl:[136,13]
> > > > > > Caused by {http://apache.org/hello_world_soap12_http}[message:ValueProductsRequest] (http://apache.org/hello_world_soap12_http%7D%5Bmessage:ValueProductsRequest%5D) not exist.
> > > > > 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> > > > > 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)
> > > > > 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> > > > > ----
> > > > > Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
> > > >
> > > >
> > > > --
> > > > 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> > > > 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> > > > 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)
> > > > 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> > > > ----
> > > > Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
> > >
> > >
> > > --
> > > 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> > > 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> > > 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)
> > > 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> > > ----
> > > Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
> >
> > --
> > 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> > 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> > 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)
> > 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
> > ----
> > Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
>
> --
> 您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
> 要在此论坛发帖,请发电子邮件到 cxf...@googlegroups.com (mailto:cxf...@googlegroups.com)
> 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com (mailto:cxf-zh-un...@googlegroups.com)

Freeman Fang

unread,
Jan 21, 2013, 12:18:51 AM1/21/13
to cxf...@googlegroups.com
Both CXF and Metro implement JAXWS spec(JSR 224), though Metro is the RI( reference implementation). As you post your question here and I'm a contributor of CXF so yeah, of course I recommend  use CXF, CXF pass the JAXWS TCK but it's more than a JAXWS implementation, take a look at [1] to get more concrete ideas what CXF can offer you.

-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat

Jingbin Li

unread,
Jan 21, 2013, 10:47:36 AM1/21/13
to cxf...@googlegroups.com
Willem, 谢谢你的回复。
在cxf自带的例子里我没有找到SOAP over TCP, 我只找到了SOAP over JMS的例子。请问哪里可以找到CXF SOAP over TCP的例子?谢谢

2013/1/20 Willem jiang <willem...@gmail.com>
 要退订此论坛,请发邮件至 cxf-zh-un...@googlegroups.com

Jingbin Li

unread,
Jan 21, 2013, 9:44:22 PM1/21/13
to cxf...@googlegroups.com
谢谢你和willem的耐心回复。
抱歉我的目的在前面表述的不清楚。我想写一个soap service,能够根据多种不同的soap请求,做相应的soap回复。client可能是java写的,也可能是C++写的。由于每一种soap的具体格式是不确定的,我需要自己手动实现soap <-> object的转换。 但我希望在CXF 层面能实现根据soap body root element的绑定,比如说messageA 能自动绑定到handleMessageA类。messageB自动绑定到handleMessageB。。。之所以需要绑定到soap body root element,是因为整个soap structure是由soap body root element value决定的。

我看了 jaxws 的dispatch,provider APIs,下面的代码可以实现server内从soap <-> object的转换,以及生成soap回复。
E.g. RegisterServerSOAPHandler.java

@WebServiceProvider(portName="registerServerPort" serviceName="registerServer")
@ServiceMode(value="Service.Mode.MESSAGE")
public class RegistServerSOAPHandler implements Provider<SOAPMessage>
{
..........
public SOAPMessage invoke(SOAPMessage request_)
{
   //TODO, parsing logic here 
   SOAPBody requestBody = request_.getSOAPBody();
            ....
   MessageFactory mf = MessageFactory.newInstance();
   SOAPFactory sf = SOAPFactory.newInstance();
   SOAPMessage response = mf.createMessage();
   
   return response;
}
---------
}

但我不清楚的是在CXF里如何实现message soap body element <-> implementation class的绑定。上面的WebServiceProvider annotation就足够了吗?还是我要在cxf-servlet.xml单独描叙?如果需要,请问如何做?

谢谢

2013/1/21 Freeman Fang <freema...@gmail.com>
Reply all
Reply to author
Forward
0 new messages