针对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的朋友试试!
分享到:
相关推荐
这是word的2016版本快捷键设置导出,如果需要也可以下载,不过本文件更多是自用的,谢谢各位理解。
Ubuntu Powerful Hacks and Customizations 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,...
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 Powerful Hacks and Customizations.pdf en
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 ...
for the Microsoft Certified Technology Specialist (MCTS) Windows Embedded CE 6.0 Application Development certification exam. By using this preparation kit, you can maximize your performance on the ...
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 ...
这本书被一版再版,详细介绍了大量常用技巧和这些技巧的扩展。它有多个层面,你可以简单的使用这些技巧,更可以理解这些技巧,使你对linux系统的理解更上层楼
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. ...
华硕主板B660M wifi驱动,下载可以wifi上网
Know where to go in the setup area to make customizations Create dynamic reports and dashboards View Lightning on a mobile device Train other users on common day-to-day activities within Lightning Who...
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 ...
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 ...
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 ...
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 ...