xfire 客户端代码分析
发布时间:2020-12-17 02:36:38 所属栏目:安全 来源:网络整理
导读:? xfire客户端代码可以利用工具生成,但有些情况下工具没法生成,无法只能手工编写。本文记录手工编写客户端代码过程。 目录: QName的解释 一、分析自动生成的代码 二、自定义生成的代码 QName的解释 1.来历:qname是 qualified name 的简写 2.构成:由名字
?
xfire客户端代码可以利用工具生成,但有些情况下工具没法生成,无法只能手工编写。本文记录手工编写客户端代码过程。
目录:
QName的解释
1.来历:qname是
qualified name 的简写
2.构成:由名字空间(NS)前缀(prefix)以及冒号(:),还有一个元素名称构成 3.举例: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ???? xmlns="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" ???? version="1.0"> ? <xsl:template match="foo"> ??? <hr/> ? </xsl:template> </xsl:stylesheet> xsl是名字空间前缀,template是元素名称,xsl:template 就是一个qname。代表<xsl:template match="foo">标签 4.总结:qname无非是有着特定格式的xml元素,其作用主要是增加了名字空间,比如有同样的元素名称,而名字空间不同的情况。举例如下
一、分析自动生成的代码。2个包中文件如下
?? ??com.reyosoft.app.webclient
?????? ??? ? XFireClientFactory.java ?? ??? ? SigManager.java ?? ??? ? SigManagerImpl.java ???? com.reyosoft.app.webclient.entity? ???????? package-info.java ???????? ObjectFactory.java ???????? SigServiceCategory.java ???? 1,package-info.java? 看了就明白 @javax.xml.bind.annotation.XmlSchema(NS = "http://www.reyosoft.com/webservice") package com.reyosoft.app.webclient.entity; ??? 2, SigServiceCategory.java package com.reyosoft.app.webclient.entity; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "NewComplexType1" public class SigServiceCategory { ??? @XmlElement(name = "ESSC",required = true)????? ??? protected List<SigServiceCategory. Data > data; ? ??? public List<SigServiceCategory. > getData() { ??????? if ( data == null) { ??????????? = new ArrayList<SigServiceCategory. >(); ??????? } ??????? return this. ; ??? } ? ??? @XmlAccessorType(XmlAccessType.FIELD) ??? @XmlType(name = "" ??? public static class Data { ??????? @XmlElement(name = "SCID",required = true) ??????? protected String scid; ??????? @XmlElement(name = "SCCategory",required = true) ??????? protected String scCategory; ??????? @XmlElement(name = "SCSub",required = true) ??????? protected String scSub; ??????? @XmlElement(name = "SCDesc",required = true) ??????? protected String scDesc; ??????? @XmlElement(required = true) ??????? protected String sigNo; ???????? 省略setter和getter ??? } } "蓝色"代码是wsdl中对应的<wsdl:types>标签下的对应的值。例如 NewComplexType1 和 ESSC 对应
??? <wsdl:types>
??? ??? <xsd:schema? targetNS=""? ??? xmlns:tns=""> ?? ??? ??? ??<xsd:complexType name="NewComplexType1"> ??? ??? ??? ??? <xsd:sequence> ??? ??? ??? ??? ??? <xsd:element name="ESSC" minOccurs="0"??? maxOccurs="unbounded"> ??? ??? ??? ??? ??? ??? <xsd:complexType> ??? ??? ??? ??? ??? ??? ??? <xsd:sequence> ??? ??? ??? ??? ??? ??? ??? ??? <xsd:element name="SCID" ??? ??? ??? ??? ??? ??? ??? ??? ??? type="xsd:string"> ??? ??? ??? ??? ??? ??? ??? ??? </xsd:element> ??? ??? ??? ??? ??? ??? ??? ??? <xsd:element name="SCCategory" ??? ??? ??? ??? ??? ??? ??? ??? ??? type="xsd:string"> ??? ??? ??? ??? ??? ??? ??? ??? </xsd:element> ??? ??? ??? ??? ??? ??? ??? ??? <xsd:element name="SCSub" ??? ??? ??? ??? ??? ??? ??? ??? ??? type="xsd:string"> ??? ??? ??? ??? ??? ??? ??? ??? </xsd:element> ??? ??? ??? ??? ??? ??? ??? ??? <xsd:element name="SCDesc" ??? ??? ??? ??? ??? ??? ??? ??? ??? type="xsd:string"> ??? ??? ??? ??? ??? ??? ??? ??? </xsd:element> ??? ??? ??? ??? ??? ??? ??? ??? <xsd:element name="sigNo" ??? ??? ??? ??? ??? ??? ??? ??? ??? type="xsd:string"> ??? ??? ??? ??? ??? ??? ??? ??? </xsd:element> ??? ??? ??? ??? ??? ??? ??? </xsd:sequence> ??? ??? ??? ??? ??? ??? </xsd:complexType> ??? ??? ??? ??? ??? </xsd:element> ??? ??? ??? ??? </xsd:sequence> ??? ??? ??? </xsd:complexType> ?? ??? ???? ........ ?3 , ObjectFactory.java package com.reyosoft.app.webclient.entity; import javax.xml.bind.annotation.XmlRegistry; @XmlRegistry public class ObjectFactory { ??? public ObjectFactory() { ??? } ? ? public SigServiceCategory createNewComplexType1(){ ??????? return new SigServiceCategory(); ??? public SigServiceCategory.Data createNewComplexType1ESSC(){ ??????? return new SigServiceCategory.Data(); } 请注意这里的两个函数名规则。不用我说明应该知道怎么回事了吧! 4, SigManager.java package com.reyosoft.app.webclient; @WebService(name = SIG_SN , ?? ??? ??? ??? ??? targetNS = SIG_NS) public interface SigManager { ?? ? ??? @WebMethod(operationName = "getServiceCategory",action = SIG_NS + " es_sig/getServiceCategory") WebResult(name = "getServiceCategoryResponse",targetNS = SIG_NS) ??? public SigServiceCategory getServiceCategory( ??????????? @WebParam(name = "getServiceCategoryUN",0);">??????????? String getServiceCategoryUN, getServiceCategoryPW",0);">??????????? String getServiceCategoryPW); } 5, SigManagerImpl.java package com.reyosoft.app.webclient; @WebService(??serviceName = SIG_SN , ?? ??? ??? ??? ??? ??targetNS = SIG_NS,255);">endpointInterface = "com.reyosoft.app.webclient.SigManager") @SOAPBinding( style = SOAPBinding.Style.DOCUMENT, ?? ??? ??? ??? ? ? ? use = SOAPBinding.Use.LITERAL,255);">parameterStyle = SOAPBinding.ParameterStyle.BARE) public class SigManagerImpl implements SigManager{ ?? ? /** ???? * {@inheritDoc} ???? */ ??? public SigServiceCategory getServiceCategory(String getServiceCategoryUN,String getServiceCategoryPW) { ??????? throw new UnsupportedOperationException(); ??? } } 6,255);">XFireClientFactory.java 不需要改动 ???? 二、手动添加。 ???? 模仿自动添加的样例,需要修改的地方我已经用下划线标识了。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |