0

I have several custom faults and one of them when received in response is as follows :

<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>

I am asked to remove the namespace (xmlns)that comes within the fault(for all faults) i.e :

<NonExistingEntityFault xmlns="http://xmlns.scania.com/logistics/schema/transport/v1">

As mentioned in threads like these, in the xsd file, I tried changing :

<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"

to

<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="unqualified"

and regenerated the classes but I still get ns. How shall I proceed ?

The generated fault class 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>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="FaultTypeDescription" type="{http://xmlns.scania.com/logistics/schema/transport/v1}FaultTypeDescription"/>
 *         &lt;element name="CustomMessage" type="{http://xmlns.scania.com/logistics/schema/transport/v1}CustomMessage" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/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;
    }

}

The xsd is :

<?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>
Community
  • 1
  • 1
Kaliyug Antagonist
  • 3,512
  • 9
  • 51
  • 103
  • for starter, can you post your xsd with the fault definition? Please remember that the qualified is hierarchical and hereditary, as a result if you have it in the schema element declaration it will apply to ALL elements where such modifier is not specified, because if it's specified, in a specific subelement of the schema element, its local value will be in place rather than the generic "father" value... – witchedwiz May 20 '15 at 14:34
  • xsd added which contains the fault defn. – Kaliyug Antagonist May 20 '15 at 14:39
  • is that xsd old? because i see plainly a – witchedwiz May 20 '15 at 14:43
  • Can you elaborate 'old' ? I'm unable to get the pointers you are providing – Kaliyug Antagonist May 20 '15 at 14:46
  • You said that you changed the xsd for fault to unqualified.. yet in the xsd that you posted the schema element for fault has elementFormDefault="qualified" which will in case override (for its element). So if a second xsd with elementFormDefault="unqualified" import it for definition, all element included in this second xsd will anyway use fullyqualified approach.. – witchedwiz May 20 '15 at 14:50
  • As I mentioned, I had changed the xsd to include elementFormDefault="unqualified" but it didn't work so I have reverted it to elementFormDefault="qualified" – Kaliyug Antagonist May 20 '15 at 14:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78337/discussion-between-kaliyug-antagonist-and-witchedwiz). – Kaliyug Antagonist May 20 '15 at 14:53

0 Answers0