用cxf做webserver是生成自己指定的报文

tangcx 2009-04-10 04:55:43
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlType;

/**
* <p>Java class for AdcSiRequest complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="AdcSiRequest">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="ActionCode" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="BizCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="Dealkind" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="Priority" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="SIAppID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="SvcCont" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="TestFlag" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="TimeStamp" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="TransID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="Version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace="http://adc.siinterface.com/",name = "AdcSiRequest", propOrder = {
"actionCode",
"bizCode",
"dealkind",
"priority",
"siAppID",
"svcCont",
"testFlag",
"timeStamp",
"transID",
"version"
})
public class AdcSiRequest {
@XmlElement(name = "ActionCode" ,namespace="http://adc.siinterface.com/")
protected int actionCode;
@XmlElement(name = "BizCode" ,namespace="http://adc.siinterface.com/")
protected String bizCode;
@XmlElement(name = "Dealkind" ,namespace="http://adc.siinterface.com/")
protected int dealkind;
@XmlElement(name = "Priority" ,namespace="http://adc.siinterface.com/")
protected int priority;
@XmlElement(name = "SIAppID" ,namespace="http://adc.siinterface.com/")
protected String siAppID;
@XmlElement(name = "SvcCont" ,namespace="http://adc.siinterface.com/")
protected String svcCont;
@XmlElement(name = "TestFlag" ,namespace="http://adc.siinterface.com/")
protected int testFlag;
@XmlElement(name = "TimeStamp" ,namespace="http://adc.siinterface.com/")
protected String timeStamp;
@XmlElement(name = "TransID" ,namespace="http://adc.siinterface.com/")
protected String transID;
@XmlElement(name = "Version" ,namespace="http://adc.siinterface.com/")
protected String version;

public int getActionCode() {
return actionCode;
}
public void setActionCode(int value) {
this.actionCode = value;
}
public String getBizCode() {
return bizCode;
}
public void setBizCode(String value) {
this.bizCode = value;
}
public int getDealkind() {
return dealkind;
}
public void setDealkind(int value) {
this.dealkind = value;
}

public int getPriority() {
return priority;
}
public void setPriority(int value) {
this.priority = value;
}
public String getSIAppID() {
return siAppID;
}
public void setSIAppID(String value) {
this.siAppID = value;
}
public String getSvcCont() {
return svcCont;
}
public void setSvcCont(String value) {
this.svcCont = value;
}
public int getTestFlag() {
return testFlag;
}
public void setTestFlag(int value) {
this.testFlag = value;
}
public String getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(String value) {
this.timeStamp = value;
}
public String getTransID() {
return transID;
}
public void setTransID(String value) {
this.transID = value;
}
public String getVersion() {
return version;
}
public void setVersion(String value) {
this.version = value;
}

}


private static void AuthenRequest(String token)
{
StringBuffer StrBuffer= new StringBuffer();
//StrBuffer.append(" <?xml version=\"1.0\" encoding=\"utf-8\"?>");
StrBuffer.append(" <AuthenRequest>");
StrBuffer.append(" <BODY>");
StrBuffer.append(" <SICode>0000123 </SICode> ");
StrBuffer.append(" <TOKEN>"+token+" </TOKEN> ");
StrBuffer.append(" <ACTION>0dsdsssd </ACTION>");
StrBuffer.append(" </BODY>");
StrBuffer.append(" </AuthenRequest>");

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

factory.setAddress("http://241.01.77.27/ADCInterfaceM/ADCInterfaceForSI.asmx");
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(SIInterfaceForADCSoap.class);

SIInterfaceForADCSoap hello = (SIInterfaceForADCSoap)factory.create();

AdcSiRequest request = new AdcSiRequest();
request.setActionCode(1);
request.setBizCode("SI101");
request.setDealkind(1);
request.setPriority(0);
request.setSIAppID("CO");
request.setSvcCont(StrBuffer.toString());
request.setTestFlag(1);
request.setTimeStamp(StringUtil.currentTime());
request.setTransID("1111");
request.setVersion("1.0");

AdcSiResponse response = hello.adcsiInterface(request);

if(response != null)
System.out.println(response.getSvcCont());
else
System.out.println("response is null");
}


现在程序生成

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ADCSIInterface xmlns="http://adc.siinterface.com/">
<request>
<ActionCode>1 </ActionCode>
<BizCode>SI102 </BizCode>
<Dealkind>1 </Dealkind>
<Priority>0 </Priority>
<SIAppID>CHECKOO </SIAppID>
<SvcCont>sddssddsds </SvcCont>

<TestFlag>1 </TestFlag>
<TimeStamp>200903301220000120 </TimeStamp>
<TransID>1111 </TransID>
<Version>1.0 </Version>

</request>

</ADCSIInterface>
</soap:Body>

</soap:Envelope>

----------------------------
这种形式的报文


怎么生成以下报文呢?????????????????????????????????


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ADCSIInterface xmlns="http://adc.siinterface.com/">
<request>
<ActionCode xmlns='http://adc.siinterface.com/'>1 </ActionCode>
<BizCode xmlns='http://adc.siinterface.com/'>SI102 </BizCode>
<Dealkind xmlns='http://adc.siinterface.com/'>1 </Dealkind>
<Priority xmlns='http://adc.siinterface.com/'>0 </Priority>
<SIAppID xmlns='http://adc.siinterface.com/'>CHECKOO </SIAppID>
<SvcCont xmlns='http://adc.siinterface.com/'>sddssddsds </SvcCont>

<TestFlag xmlns='http://adc.siinterface.com/'>1 </TestFlag>
<TimeStamp xmlns='http://adc.siinterface.com/'>200903301220000120 </TimeStamp>
<TransID xmlns='http://adc.siinterface.com/'>1111 </TransID>
<Version xmlns='http://adc.siinterface.com/'>1.0 </Version>
</request>
</ADCSIInterface>
</soap:Body>

</soap:Envelope>


找一半天都没找天java的,.net倒是大把,还是跟跟微软混好点.
应该是用注解搞,没做过不知道怎么做....有谁做过啊
...全文
132 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangcx 2009-04-10
  • 打赏
  • 举报
回复
自己顶一下!
随着通信电子技术的迅速发展,信息技术给家居行业产生了深远的影响,家居环境的智能化监控已经成为智能家居的一个重要的发展方向。人们逐渐对自己的生活提出一种更高的要求,他们需要一种智能化、可交互,并且融合现代创新科技的产品来改善他们的生活环境,使他们生活更加安全、舒适、便捷、智能。本文根据智能家居的发展背景和研究现状,并且从实用性和可行性角度出发,研究设计了一种基于STM32单片机的智能家居系统。该系统由一个多功能综合的技术系统组成,各个多功能子系统间具有协同配合能力。基于STM32单片机实现的功能子系统包括:智能温度检测,智能湿度检测,智能烟雾/火灾检测智能检测,无线传输,人机交互机构,风扇调节,报警模块。 整个系统分为前端51单片机采集板和后端STM32单片机接收板。 采集板使用DHT11温湿度传感器、MQ烟雾传感器完成室内家居环境的采集。然后通过nRFL24L01将采集到的数据发送给后端。接收板使用LCD1602完成数据显示、使用蜂鸣器模块报警,使用风扇驱动模块调节室内家居环境。本文完成了智能家居控制系统前端、后端软硬件的设计,使用Altium designer绘制了电路原理图,使用Keil C完成了51单片机和STM32单片机的编程与调试。 最后,对本文设计的基于STM32的智能家居控制系统进行部署调试。试验结果表明,该系统可成功应用在智能家居环境检测调节和火灾安全防护的领域,可提高家居生活智能化水平。

67,535

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧