Maven 用于构建 SOA 服务和客户端?
我更改了标题以概括这个问题,该问题实际上并非特定于 Axis2。我最终完全放弃了 Axis2,转而使用 Metro/JAX-WS,但现在我正在认真考虑放弃两者并转而使用 OpenSAML。我在这里努力寻求答案的真正问题是,如何构建实际可用的复杂的、基于标准的 SOA 服务。
最初的措辞是:有人可以粘贴一个 Maven pom 的工作示例来调用 Axis2 java2wsdl 以及我可以接受的默认值吗?这是一个表现良好的命令行咒语。
-o target/generated-sources/java2wsdl \
-l "http://localhost:9763/services/PolicyService" \
-tn urn:sesgg:sc:security:1.0.spec.PolicyService \
-tp ps \
-stn urn:oasis:names:tc:SAML:2.0:protocol \
-stp samlp \
-of PolicyService.wsdl \
-sn PolicyService \
-cp "../../Schema/target/Schema-1.0-SNAPSHOT.jar target/PolicyService-1.0-SNAPSHOT.jar" \
-cn com.technica.pbac.ps.PolicyService \
我所做的一切最终都会得到非常奇怪的结果;例如奇怪的反向命名空间(例如http://xmldsig._09._2000.w3.org/xsd)。您能解释一下这是为什么以及如何阻止它吗?
似乎有很多 java2wsdl 期望完全不同的参数,命令行和 maven pom 之间几乎没有一致性。
I changed the title to generalize this question which really isn't specific to Axis2. I eventually gave up on Axis2 altogether and switched to Metro/JAX-WS but am now seriously considering giving up on both and switching to OpenSAML. The real question I'm struggling to get answered here is, how to build complex standards-based SOA services that actually work.
The original phrasing was: Could someone paste in a working example of maven pom to invoke Axis2 java2wsdl with defaults I can live with? Here's a command line incantation that behaves sort of OK.
-o target/generated-sources/java2wsdl \
-l "http://localhost:9763/services/PolicyService" \
-tn urn:sesgg:sc:security:1.0.spec.PolicyService \
-tp ps \
-stn urn:oasis:names:tc:SAML:2.0:protocol \
-stp samlp \
-of PolicyService.wsdl \
-sn PolicyService \
-cp "../../Schema/target/Schema-1.0-SNAPSHOT.jar target/PolicyService-1.0-SNAPSHOT.jar" \
-cn com.technica.pbac.ps.PolicyService \
Everything I do winds up with really squirrely results; e.g. weird reversed namespaces (http://xmldsig._09._2000.w3.org/xsd for example). Could you explain why this is and how to stop it?
There seems to be a lot java2wsdl's out there that expect entirely different arguments, with little consistency between command line and maven pom.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有回复,所以我将发布我自己的实验的当前结果来帮助其他人
类似的问题。在测试完成之前不能保证这是正确的,但至少现在我得到了可以在 Eclipse 中查看的结果:
一个警告:我真的怀疑它在单个阶段中运行 jaxb、java2wsdl、wsdl2java 和编译阶段的正确性pom。目前 java2wsdl 在 wsdl2java 之后运行,这显然是不正确的。这个 pom 是双重可疑的,因为 java2wsdl 需要一个已编译的 jar 才能运行,并且似乎正在使用之前运行留下的 jar。 mvn clean 后重新开始工作真是太痛苦了。我可能最终会将它分成几个 pom,并在这样做时调整这个答案。
No responses so I'll post current results of my own experiments to help others with
similar problems. Can't guarantee this is correct until testing is finished but at least now I'm getting results I can bear looking at in Eclipse:
One caution: I really doubt its right to be running jaxb, java2wsdl, wsdl2java and compile phases in a single pom. Currently java2wsdl runs after wsdl2java this way which obvously isn't right. This pom is doubly suspicious since java2wsdl needs a compiled jar to run, and seems to be using the one left over from previous runs. Its a bear to get working again after mvn clean. I'll probably wind up splitting it into several poms and will adjust this answer when I do.
我答应用一些近似“正确”的东西来扩展这个答案。这是迄今为止的进展,我仍然不能完全确定它是否 100% 正确。稍后会详细介绍。
这一切都基于 Oasis 发布的用于定义 XACML 和 SAML-P 的 XACML 标准的架构堆栈。 XSD 已被收集到 Commons-Schema 模块(未显示)中,经过调整以修复多个 Oasis 错误,并使用 JAX-B 编译为 Java 类。这些类是下述服务的基础。 schema.episode.path 和 schema.catalog.path 属性指向此模块中的文件。
我将每个服务(本例中为 PolicyService)拆分为两个 Maven 模块。 PolicyService-Svc 是服务,其 pom 如下所示:
PolicyService-Proxy 是任何客户端或服务都可以用来调用该服务的通用代理代码(更多有关此问题的信息请参见下文)。它的 pom 看起来像这样:
现在是问题,我非常感谢您的建议。尽管 Commons-Schema 为所有模式提供了已编译的 java 类,但 wsgen 坚持使用新生成的 xsd 生成 wsdl,这些 xsd 在各种方面略有不同且略有不正确。
作为不正确和不同的一个示例,SAML 定义了一个与另一个模式中的相同名称冲突的扩展元素。所以我在基本 Commons-Schema 中修复了它,如下所示:
但是 wsgen/wsimport 忽略了此更正,因此冲突再次出现。令人愤怒并且对构建绝对致命。
另一个是省略必需的包含,因此 Eclipse 验证将它们报告为错误,直到手动更正。我的解决方法是定期将生成的 wsdl 和 xsd 从目标文件夹复制到 src/main/webapp/WEB-Inf/wsdl,手动修复它们,并调整 poms 以使用此文件夹而不是生成的内部目标。这适用于从非服务客户端调用服务。我将相同的 wsdls 和 xsd 复制到类似的客户端文件夹,并确保 pom 引用这些文件,而不是 jaxws 在该模块中生成的文件。
当任何服务需要通过其代理调用另一个服务时,就会出现我无法解决的问题。调用服务的代理 jar(其重要基础类的版本略有不同)现在与调用服务 jar(基于 Commons-Schema 的 JAXB 生成的类)混合在一起,这会导致无穷无尽的麻烦。
有人可以建议吗?谢谢!
I promised to extend this answer with something approximately "right". Here is progress to date, which I'm still not absolutely sure is 100% correct. More about that later.
This is all based on the stack of schema Oasis publishes to define the XACML and SAML-P for XACML standards. The XSD's have been gathered into a Commons-Schema module (not shown), tweaked to fix several Oasis errors, and compiled to Java classes with JAX-B. These classes are the foundation for the services described below. The schema.episode.path and schema.catalog.path properties point to files in this module.
I split each service (PolicyService in this case) into two maven modules. PolicyService-Svc is the service and its pom looks like this:
PolicyService-Proxy is generic proxy code that any client or service can use to invoke that service (more about problems with this below). Its pom looks like this:
Now for the problems, which I'd really appreciate advice on. Even though Commons-Schema provides compiled java classes for all schema, wsgen insists on producing a wsdl with newly-generated xsds, which are slightly different and slightly incorrect in various ways.
As one example of incorrect and different, SAML defines an Extensions element that conflicts with the same name in another schema. So I repaired it in the base Commons-Schema like this:
But wsgen/wsimport omits this correction so the conflict turns up again. Infuriating and absolutely fatal to the build.
Another is omitting required includes so eclipse validation reports them as errors until hand-corrected. My workaround is to periodically copy the generated wsdl and xsds from the target folder to src/main/webapp/WEB-Inf/wsdl, repair them by hand, and tweak the poms to use this folder instead of the generated one inside target. This works for invoking services from non-service clients. I copy the same wsdls and xsds to a similar client folder and ensure that the pom references these, not the ones jaxws generates in that module.
The problem I can't solve occurs when any service needs to invoke another service via its proxy. The calling service's proxy jar (with its slightly different versions of important foundation classes) is now mixed in with the calling service jars (based on Commons-Schema's JAXB-generated classes), which causes no end of trouble.
Can someone please advise? Thanks!
这个问题的最终答案确实是放弃尝试修复损坏的模式和工具,转而使用 OpenSAML,它已经做到了这一点。这对于 XACML 2.0 编译器和基于它的 Web 服务来说效果很好。但 XACML 3.0 编译器的表现却很糟糕,因为 OpenSAML 不支持 XACML 3.0 并且没有计划这样做,所以我必须自己处理这个问题。但凭借 XACML 2.0 的经验,我最终让两者都工作起来。这个项目比原本要痛苦得多,而“强大”的工具只会让事情变得更加困难。
The ultimate answer to this question was indeed to give up on trying to fix busted schemas and tools and switch to OpenSAML, which has already done that. This worked fine for the XACML 2.0 compiler and web services based on it. But it fell flat for the XACML 3.0 compilers because OpenSAML doesn't support XACML 3.0 and has no plans to do so, so I had to handle that myself. But with experience with XACML 2.0 to build on, I eventually got both working. This project was far more painful than it had to be and "powerful" tools just made it harder.