针对WCF Service WSDL,记录下我的一些使用体验:
1.根据WCF Service WSDL生产client端java代码可能会有JAXBElement<T>这样的properties,JAXB2.0 建议通过一些定制可生成一些对java更友好的代码,详细文档请看
这里
我的步骤如下:
#1.创建一个txt文本(暂命名为“bindings.txt”),如下:
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:globalBindings generateElementProperty="false"/>
</jaxb:bindings>
#2.使用以下命令行生产java客户端代码:
wsdl2java -p your.package -b bindings.txt yourdownloaded.wsdl
Or
wsimport -p your.package -b bindings.txt -keep yourdownloaded.wsdl
注意这里使用了“-b bindings.txt”来添加一些额外定制。
#3.这样生成的client代码可获得对java更友好的支持。
2.在XML节点和java objects之间进行unmarshal的时候,针对从xml文件到java objects无法成功解组时,获得的都是null,如果你觉得你的XML文件格式都是正确的前提下,检查下你生成的客户端代码文件“package-info.java”,其中你可能会遇到如下代码:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.vuebill.com/WebService/2/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
请留意下elementFormDefault属性,elementFormDefault属性用来设置xml的实例中子元素是否一定需要有命名空间限定,对于xml<-->java objects之间的转换时,很有可能使用了命名空间从而影响xml节点的映射,可以尝试将“package-info.java”elementFormDefault相关的值移除,再尝试unmarshal。
(以上纯属个人经历,只是希望可以多注意下package-info.java这个文件)
3.JAXB unmarshalling exception : unexpected element
可尝试检查具体对应生成的java client object代码,在对应的@XmlRootElement、@XmlElement 添加namespace来具体指明你的namespace,如下:
@XmlElement(name="your xml node name", namespace="http://your name space")
Good luck!
小结:
调用.Net提供的webservice,会遇到一些关于WSDL、导入xsd文件、生成客户端代码等等问题,由于本身语言方面的各种问题,需要更多一点的耐心。
suds是一个不错的lightweight soap-based web service client(python),其中可以不用生成客户端代码我觉得非常好用,而且使用也很方便,推荐喜欢python的朋友试试!
分享到:
相关推荐
Ubuntu Powerful Hacks and Customizations 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,...
这是word的2016版本快捷键设置导出,如果需要也可以下载,不过本文件更多是自用的,谢谢各位理解。
ons can be added such as JIRA Agile for Agile tracking and Groovy scripts, a powerful tool for administering customizations for customizations. This book explains how to master the key ...
Implementing Interrupt Service Routines (ISRs) and Interrupt Service Threads (ISTs) and Marshaling Data Between Kernel-Mode and User-Mode Components** - Understanding ISRs and ISTs and their roles ...
### Ubuntu® Powerful Hacks and Customizations #### 书籍概述 《Ubuntu® Powerful Hacks and Customizations》是由Neal Krawetz博士撰写的专著,由Wiley Publishing, Inc.出版于2010年。该书深入浅出地介绍了...
Ubuntu is a community developed, Linux-based operating system that is perfect for laptops, desktops, and servers, and is used by millions of people around the world. This book provides you with ...
ons can be added such as JIRA Agile for Agile tracking and Groovy scripts, a powerful tool for administering customizations for customizations. This book explains how to master the key ...
ons can be added such as JIRA Agile for Agile tracking and Groovy scripts, a powerful tool for administering customizations for customizations. This book explains how to master the key ...
### Ubuntu 强大技巧与定制化方法概览 #### 标题解读:Ubuntu 强大技巧与定制化方法 本书《Ubuntu 强大技巧与定制化方法》由 Neal Krawetz 博士撰写,旨在为 Ubuntu 用户提供一系列实用且深入的技术指导。...
Make use of the latest Universal Windows app features, alongside customizations for specific platforms and screen sizes. Bring your apps to life with live tiles, notifications, and sharing. Prepare ...
1)....Added: HKCU\Software\EurekaLab\Viewer\4.0\UI\Statuses registry key to allow status customizations in Viewer 2)....Added: "Disable hang detection under debugger" option 3)....Fixed: Wrong button ...
Make use of the latest Universal Windows app features, alongside customizations for specific platforms and screen sizes. Bring your apps to life with live tiles, notifications, and sharing. Prepare ...
The CD-ROM accompanying this book contains a keyboard quick reference card, which you may edit to include your customizations. This way, you do not need to learn difficult keybindings. ...
【标题】"yale_pui_customizations"是一个项目,它专注于对耶鲁大学的用户界面(PUI,可能是个性化用户界面或平台用户界面)进行定制和优化,以适应耶鲁大学的独特美学和功能需求。这个项目的核心是通过HTML语言来...
To get the source codes, special customizations licenses please contact our sales department at sales [at] jumpeyecomponents.com JScharts by JumpeyeComponents, Smartketer LLC is licensed under a ...
This is the Ember Data book you have been waiting for. Lots of books and tutorials start off teaching Ember with Ember Data. This is great, especially if you are in control of your API, but what if ...
Edit Android_configuration.mk and apply your customizations to the ./configure parameters, if needed. Initialize Android build environment: cd . build/envsetup.sh lunch To configure and build the...
Readers are led step-by-step from simple to complex customizations. Code snippets, screenshots, and numerous online references are provided to enable the utilization of this book as both a sequential ...
Readers are led step-by-step from simple to complex customizations. Code snippets, screenshots, and numerous online references are provided to enable the utilization of this book as both a sequential ...