我正在尝试使用SOAP Web服务,因此使用AXIS从wsdl生成类。
我已经完成了SOAP Client的实现并调用了SOAP Server。 SOAP客户端能够访问SOAP服务器,但从SOAP客户端进入SOAP服务器时,请求的正文顺序正在发生变化。
请查看以下详细信息:
SOAP UI请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prim="http://..../..Services">
<soapenv:Header />
<soapenv:Body>
<prim:UserList>
<prim:XMLRequest>
<prim:Header>
<prim:MessageID>1</prim:MessageID>
<prim:CorrelationID>1</CorrelationID>
</prim:Header>
<prim:Number>1</prim:Number>
</prim:XMLRequest>
</prim:UserList>
</soapenv:Body>
</soapenv:Envelope>
客户端向服务器发送请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<UserList xmlns="hhttp://..../..Services">
<XMLRequest>
<Number>1</Number>
<header>
<MessageID>1</MessageID>
<CorrelationID>1</CorrelationID>
</header>
</XMLRequest>
</UserList>
</soapenv:Body>
</soapenv:Envelope>
Code:
public UserListResponse UserListService(UserList request)
throws RemoteException, ServiceException {
UserListRequest xmlRequest = new UserListRequest();
Header reqHeader = request.getXMLRequest().getHeader();
Header header = new Header();
header.setCorrelationID(reqHeader.getCorrelationID());
header.setMessageID(reqHeader.getMessageID());
xmlRequest.setHeader(header);
return soapStub.UserList(xmlRequest);
}
UserListRequest代码:
/**
* <p>Java class for UserListRequest complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="UserListRequest">
* <complexContent>
* <extension base="{http://..../..Services}APIArguments">
* <sequence>
* <element name="Reference" type="{http://..../..Services}UserListReferenceTypes"/>
* <element name="Number" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserListRequest", propOrder = {
"reference",
"number"
})
public class UserListRequest extendsAPIArguments implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlElement(name = "Reference", required = true)
@XmlSchemaType(name = "string")
protected UserListReferenceTypes reference;
@XmlElement(name = "Number")
protected String number;
/**
* Gets the value of the reference property.
*
* @return
* possible object is
* {@link UserListReferenceTypes }
*
*/
public UserListReferenceTypes getReference() {
return reference;
}
/**
* Sets the value of the reference property.
*
* @param value
* allowed object is
* {@link UserListReferenceTypes }
*
*/
public void setReference(UserListReferenceTypes value) {
this.reference = value;
}
/**
* Gets the value of the number property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNumber() {
return number;
}
/**
* Sets the value of the number property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNumber(String value) {
this.number = value;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(UserListRequest.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://..../..Services", "UserListRequest"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("reference");
elemField.setXmlName(new javax.xml.namespace.QName("http://..../..Services", "Reference"));
elemField.setXmlType(new javax.xml.namespace.QName("http://..../..Services", "UserListReferenceTypes"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("number");
elemField.setXmlName(new javax.xml.namespace.QName("http://..../..Services", "Number"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
标题代码:
/**
* <p>Java class for Header complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="Header">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="MessageID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="CorrelationID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="SystemID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="RequestorID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="InstitutionID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Header", propOrder = {
"messageID",
"correlationID",
"systemID",
"requestorID"
})
public class Header {
@XmlElement(name = "MessageID")
protected String messageID;
@XmlElement(name = "CorrelationID")
protected String correlationID;
@XmlElement(name = "SystemID")
protected String systemID;
@XmlElement(name = "RequestorID")
protected String requestorID;
public Header() {
}
public Header(
java.lang.String messageID,
java.lang.String correlationID,
java.lang.String systemID,
java.lang.String requestorID) {
this.messageID = messageID;
this.correlationID = correlationID;
this.systemID = systemID;
this.requestorID = requestorID;
}
/**
* Gets the value of the messageID property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessageID() {
return messageID;
}
/**
* Sets the value of the messageID property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessageID(String value) {
this.messageID = value;
}
/**
* Gets the value of the correlationID property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCorrelationID() {
return correlationID;
}
/**
* Sets the value of the correlationID property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCorrelationID(String value) {
this.correlationID = value;
}
/**
* Gets the value of the systemID property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSystemID() {
return systemID;
}
/**
* Sets the value of the systemID property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSystemID(String value) {
this.systemID = value;
}
/**
* Gets the value of the requestorID property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRequestorID() {
return requestorID;
}
/**
* Sets the value of the requestorID property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRequestorID(String value) {
this.requestorID = value;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(Header.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://..../..Services", "Header","prim"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("messageID");
elemField.setXmlName(new javax.xml.namespace.QName("http://..../..Services", "MessageID","prim"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("correlationID");
elemField.setXmlName(new javax.xml.namespace.QName("http://..../..Services", "CorrelationID","prim"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("systemID");
elemField.setXmlName(new javax.xml.namespace.QName("http://..../..Services", "SystemID","prim"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("requestorID");
elemField.setXmlName(new javax.xml.namespace.QName("http://..../..Services", "RequestorID","prim"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
Axis正在使用Serializer&amp; deSerializer转换为xml,反之亦然。
任何人都可以就此提出建议。