公开WCF服务以便从Java / CXF轻松使用它的最佳方法是什么? [英] What is the best way to expose a WCF service so that it can be easily consumed from Java/CXF?

查看:177
本文介绍了公开WCF服务以便从Java / CXF轻松使用它的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们编写了一个WCF服务供Java商店使用,他正在使用CXF生成适配器。我们不熟悉Java,但使用basicHttpBinding,SSL和基本身份验证公开了服务。集成测试表明.NET客户端可以正常使用该服务。但是,Java商店在使用该服务时遇到了麻烦。具体来说,它们会出现以下JAXB错误:两个声明会导致ObjectFactory类发生冲突。当CXF尝试创建适配器类时,如果2个操作具有相同的名称和命名空间,则通常会导致这种情况。

We've written a WCF service to be used by a Java shop, who is using CXF to generate the adapters. We're not that familiar with Java, but have exposed the service using basicHttpBinding, SSL, and basic authentication. Integration tests show that a .NET client can consume the service just fine. However, the Java shop is having trouble consuming the service. Specifically, they getthe following JAXB error: Two declarations cause a collision in the ObjectFactory class. This is usually caused if 2 operations have the same name and namespace when CXF attempts to create adapter classes.

我们找不到任何会导致任何类型碰撞的类型或操作名称。我们已确保所有自定义类型都指定了命名空间,并且未在WSDL中的任何位置指定tempuri.org。 Java商店怀疑错误是因为生成的WSDL包含< xsd:import元素。

We can't find any type or operation names that should cause any sort of collision. We have made sure that all custom types specify a namespace, and tempuri.org is not specified anywhere in the WSDL. The Java shop suspects the error is because the generated WSDL contains <xsd:import elements.

所以,我的问题:


  • 有没有比CXF更好的方法了Java商店消耗WCF服务? Project Tango看起来很有趣,但我不知道告诉他们考虑使用它。 CXF是Java中的事实标准吗?

  • BasicHttpBinding / SSL / Basic Auth是MS推荐用于互操作方案,但客户端似乎仍然存在互操作问题。我们是否应该考虑其他绑定或设置以使其更容易使用?

  • 有没有办法将WCF配置为始终输出没有模式导入的单个WDSL?

推荐答案

两个声明导致ObjectFactory类发生冲突错误消息通常与导入无关。这是一个JAXB错误消息,通常由多个元素或类似元素导致生成的字段名称相同。例如,如果您有以下元素:

The "Two declarations cause a collision in the ObjectFactory class" error message usually has nothing to do with imports. That's a JAXB error message that is usually caused by having multiple elements or similar that cause the generated field names to be the same. For example, if you have elements like:

< element name =Foo... />

< element name =foo... />

<element name="Foo" .../> and <element name="foo" .../>

这可能会导致错误。另一个是使用像连字符和下划线这样的东西,通常是消除+上限:
< element name =doFoo... />

< element name =do_foo... />

That can cause that error. Another is using thing like hyphens and underscores and such that are usually eliminated+capped: <element name="doFoo" .../> and <element name="do_foo" .../>

使用2.1.4,您可以尝试运行wsdl2java -autoNameResolution标志。 SOMETIMES对此有所帮助,但并非总是如此。不幸的是,JAXB在这些情况下提供的信息几乎一文不值,而且很多时候找到冲突的类型只是反复试验。 : - (

With 2.1.4, you can TRY running the wsdl2java with the -autoNameResolution flag. That SOMETIMES helps with this, but not always. Unfortunately, the information that JAXB gives in these cases is nearly worthless and lots of times it's just trial and error to find the conflicting types. :-(

这篇关于公开WCF服务以便从Java / CXF轻松使用它的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆