加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

xfire 客户端代码分析

发布时间:2020-12-17 02:36:38 所属栏目:安全 来源:网络整理
导读:? xfire客户端代码可以利用工具生成,但有些情况下工具没法生成,无法只能手工编写。本文记录手工编写客户端代码过程。 目录: QName的解释 一、分析自动生成的代码 二、自定义生成的代码 QName的解释 1.来历:qname是 qualified name 的简写 2.构成:由名字
?
xfire客户端代码可以利用工具生成,但有些情况下工具没法生成,无法只能手工编写。本文记录手工编写客户端代码过程。
目录:
  • QName的解释
  • 一、分析自动生成的代码
  • 二、自定义生成的代码

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元素,其作用主要是增加了名字空间,比如有同样的元素名称,而名字空间不同的情况。举例如下
  1. 注:这是一段AS3的代码。很好说明问题。函数trace相当于println
  2. var?xml:XML?=// 定义一个XML对象
  3. <xml>
  4. ?<ns1:node?xmlns:ns1="http://www.ticore.com/ns1"/>
  5. ?<ns2:node?xmlns:ns2="http://www.ticore.com/ns2"/>
  6. ?<ns3:node?xmlns:ns3="http://www.ticore.com/ns3"/>
  7. ?<ns4:node?xmlns:ns4="http://www.ticore.com/ns4"/>
  8. </xml>;

  9. trace(xml[new?QName("http://www.ticore.com/ns1",?"node")].toXMLString());
  10. trace(xml.elements(new?QName("http://www.ticore.com/ns2",?"node")).toXMLString());
  11. trace(xml.descendants(new?QName("http://www.ticore.com/ns3",?"node")).toXMLString());
  12. trace(xml.child(new?QName("http://www.ticore.com/ns4",?"node")).toXMLString());


一、分析自动生成的代码。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" ,propOrder = { " data " } )
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 = "" ,propOrder = { "scid","scCategory","scSub","scDesc","sigNo" } )
??? 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 不需要改动
????

二、手动添加。 ???? 模仿自动添加的样例,需要修改的地方我已经用下划线标识了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读