我有几个自定义错误,其中一个在收到回复时如下:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>The chassis/transport legs for chassis 123 are not present</faultstring>
<detail>
<NonExistingEntityFault xmlns="http://xmlns.scania.com/logistics/schema/transport/v1">
<FaultTypeDescription>Faults indicating that the request message is referencing an entity not existing in the service datastore.</FaultTypeDescription>
<CustomMessage>The chassis/transport legs for chassis 123 are not present</CustomMessage>
</NonExistingEntityFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
我被要求删除故障中的命名空间(xmlns)(对于所有故障),即:
<NonExistingEntityFault xmlns="http://xmlns.scania.com/logistics/schema/transport/v1">
如threads like these中所述,在xsd文件中,我尝试更改:
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
到
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
并重新生成类但我仍然得到ns。我该怎么办?
生成的错误类NonExistingEntityFault.java
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.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="FaultTypeDescription" type="{http://xmlns.scania.com/logistics/schema/transport/v1}FaultTypeDescription"/>
* <element name="CustomMessage" type="{http://xmlns.scania.com/logistics/schema/transport/v1}CustomMessage" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"faultTypeDescription",
"customMessage"
})
@XmlRootElement(name = "NonExistingEntityFault")
public class NonExistingEntityFault {
@XmlElement(name = "FaultTypeDescription", required = true)
protected String faultTypeDescription;
@XmlElement(name = "CustomMessage")
protected String customMessage;
/**
* Gets the value of the faultTypeDescription property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFaultTypeDescription() {
return faultTypeDescription;
}
/**
* Sets the value of the faultTypeDescription property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFaultTypeDescription(String value) {
this.faultTypeDescription = value;
}
/**
* Gets the value of the customMessage property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCustomMessage() {
return customMessage;
}
/**
* Sets the value of the customMessage property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCustomMessage(String value) {
this.customMessage = value;
}
}
xsd是:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" xmlns:types="http://ws.soleil.scania.com/"
xmlns="http://xmlns.scania.com/logistics/schema/transport/v1"
targetNamespace="http://xmlns.scania.com/logistics/schema/transport/v1">
<xs:complexType name="chassisInfo">
<xs:sequence>
<xs:element name="ChassisNumber" type="xs:int" />
<xs:element name="TransportLegs" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="From" type="xs:string" />
<xs:element name="To" type="xs:string" />
<xs:element name="OutsideEU" type="xs:boolean" />
<xs:element name="ModeOfTransport" type="xs:string" />
<xs:element name="NameOfTransport" type="xs:string"
minOccurs="0" />
<xs:element name="NationalityOfTransport" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:annotation>
<xs:documentation>Two character ISO 3166-1 code for the
nationality of the transport
</xs:documentation>
</xs:annotation>
<xs:length value="2" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Departure" type="xs:dateTime"
minOccurs="0" />
<xs:element name="EstimateTimeOfArrival" type="xs:dateTime"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="TransportInformationRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="ChassisNumber" type="xs:int" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TransportInformationResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Chassis" type="chassisInfo" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="CustomMessage">
<xs:restriction base="xs:string" />
</xs:simpleType>
<xs:simpleType name="FaultTypeDescription">
<xs:restriction base="xs:string" />
</xs:simpleType>
<xs:element name="EmptyChassisFault">
<xs:complexType>
<xs:sequence>
<xs:element
fixed="Fault indicating that the request message is sending an empty/negative/invalid characters as chassis no."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="RequestMessageFormatFault">
<xs:complexType>
<xs:sequence>
<xs:element
fixed="Request message format validation fault. Note that there may be other fault message types capturing faults for more specific request message problems."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SystemResourceUnavailableFault">
<xs:complexType>
<xs:sequence>
<xs:element
fixed="Faults which are of temporary character and not caused by incorrect request messages. This message may be used to communicate that the client can expect an invocation with the same request message to work at a later time. Example: required resource of the service realization, such as a database or another service, is temporarily inaccessible."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UnknownServerFault">
<xs:complexType>
<xs:sequence>
<xs:element
fixed="Faults which are not classified to any other category. Note that there may be, although so should be avoided when possible, other undeclared fault message types as well."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NonExistingEntityFault">
<xs:complexType>
<xs:sequence>
<xs:element
fixed="Faults indicating that the request message is referencing an entity not existing in the service datastore."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InvalidReferenceFault">
<xs:complexType>
<xs:annotation>
<xs:documentation>This fault may be extended using specific faults
for specific, or specific groups of, foreign keys.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element
fixed="Faults indicating that the entity contained in the request has an invalid reference to another entity."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NotSupportedForEntityStateFault">
<xs:complexType>
<xs:annotation>
<xs:documentation>This fault may be extended using specific faults
for specific, or specific groups of, state-machine rules.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element
fixed="Faults indicating that the operation issued on an entity is not permitted due to the state of the same entity."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SecurityFault">
<xs:complexType>
<xs:annotation>
<xs:documentation>This fault may be extended for specific security
faults. Remember, however, that revealing too much information on
the inner workings of a security mechanism in fault messages may
risk the security of the solution.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element
fixed="Faults indicating that the consumer agent is failed by a authentication or authorization mechanism."
name="FaultTypeDescription" type="FaultTypeDescription" />
<xs:element minOccurs="0" name="CustomMessage" type="CustomMessage" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>