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

tangcx 2009-04-10 11:23:35
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倒是大把,还是跟跟微软混好点.
...全文
359 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangcx 2009-04-10
  • 打赏
  • 举报
回复
自己顶起来先!

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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