mercredi 22 juin 2016

WCF SOAP Service: Complex Type Properties are null

I've been trying to set up a WCF WebService using a WSDL I got provided for some time now and am getting quite frustrated it isn't working properly. The service I'm building should act as some sort of middleware receiving a SOAP message from the client (using SAP WSI / PI) and pushing the content of the message into our CMS. It seems to work a bit, but it fails on getting the values of complex types.

I'll try to be as complete as possible, but since I'm a very moderate programmer it could be I'm missing valueble information or use the wrong terms. If you're missing something to be of help, please let me know. I'm removing namespaces from the Schemas I'm sharing in an attempt to hide the customer for which I'm setting up the service.

I've received 4 files from the customer which I try to use to build my WebService.

  • 1 x Service.wsdl
  • 1 x Serivce.xsd
  • 2 x ExportXMLSchema.xsd

Since the only issue I have regards the complex types defined in the ExportXMLSchema.xsd's I'll share the content of those.

ExportXMLSchema1.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://company.org/mail/hrm/JobPublication" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://company.org/mail/hrm/JobPublication" xmlns:p7="http://company.org/mail/global/datatypes">
    <xsd:import namespace="http://company.org/mail/global/datatypes" schemaLocation="file:///c:/users/Adriaan/Documents/PostNL/Content/VacatureSite/JobPositionPublication_orig/ExportXMLSchema2.xsd"/>
    <xsd:attributeGroup name="JobPositionPublication_Enhncmnt"/>
    <xsd:group name="JobPositionPublication_Enhncmnt">
        <xsd:sequence>
            <xsd:element name="ObjectSearchID" type="p7:JobPositionPostingID" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf30a94311dfc60c00248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="PositionPlaceID" type="p7:JobPositionPostingID" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf31a94311dfc92300248143fb3c</xsd:appinfo>
                    <xsd:documentation>Formatieplaats ID</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="PositionPlaceDescription" type="p7:DescriptionHR" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf32a94311df9bfa00248143fb3c</xsd:appinfo>
                    <xsd:documentation>Formatieplaats omschrijving</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="City" type="p7:City" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf33a94311df9f3900248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="PostalCodeFrom" type="p7:PostalCode" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf34a94311dfa86b00248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="PostalCodeTo" type="p7:PostalCode" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf35a94311dfb7f900248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="AreaDescription" type="p7:DescriptionHR" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">89c7af94b14111e19869984be172d7ee</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="TemporaryWorkerType" type="p7:TemporaryWorkerType" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">767caf37a94311dfa43d00248143fb3c</xsd:appinfo>
                    <xsd:documentation>THK</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="PublicationFunctionID" type="p7:PublicationFunctionID" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">ca6011b0a94711dfbc1200248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="JobTitle" type="p7:DescriptionHR" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">c0807df0a94811dfc40e00248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="JobID" type="p7:JobPositionPostingID" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">c0807df1a94811df8d5000248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Availability" minOccurs="0" maxOccurs="unbounded" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">d48077a0a94911dfa0bc00248143fb3c</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="DayOfWeek" type="p7:DayOfWeek">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">e9bfdac0bc0411df9b5e18a9058b3aa3</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="DayPart" type="p7:DayPart">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">e9bfdac1bc0411dfbee818a9058b3aa3</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="TeamID" type="p7:TeamID" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21a398b3c311e1c9ba78e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="TeamIDDescription" type="p7:DescriptionHR" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21a399b3c311e1a1f678e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="AreaID" type="p7:AreaID" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21a39ab3c311e1bf1478e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="AreaIDDescription" type="p7:DescriptionHR" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">4f871a83b3c911e1b30c78e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="Address" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21a39db3c311e1bef978e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="Street" type="p7:StreetNameHR" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a39bb3c311e187e278e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="City" type="p7:City" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a39cb3c311e18f8e78e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="PostalCodeFrom" type="p7:PostalCode" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">943704b5b3c211e1c47678e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="PostalCodeTo" type="p7:PostalCode" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">943704b6b3c211e1b3f578e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="AreaDescription" type="p7:DescriptionHR" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">943704b7b3c211e186c378e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="WorkAgreementExtra" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a2b3c311e19c5178e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="HourPerDayMin" type="p7:Hours" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a39eb3c311e1901e78e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="HourPerDayMax" type="p7:Hours" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a39fb3c311e1927578e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="HourPerWeekMin" type="p7:Hours" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a0b3c311e197c978e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="HourPerWeekMax" type="p7:Hours" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a1b3c311e1c17078e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="Depot" minOccurs="0" maxOccurs="unbounded" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a6b3c311e1b8c278e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="DepotPostalCode" type="p7:PostalCode" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a3b3c311e1a2f178e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="DepotStreet" type="p7:StreetNameHR" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a4b3c311e1bf2478e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="DepotCity" type="p7:City" minOccurs="0">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21a3a5b3c311e19be578e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="AvailabilityOptional" minOccurs="0" maxOccurs="unbounded" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21c3c9b3c311e1ce3b78e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="DayOfWeekOpt" type="p7:DayOfWeek">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21c3c7b3c311e18cea78e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="DayPartOpt" type="p7:DayPart">
                            <xsd:annotation>
                                <xsd:appinfo source="http://sap.com/xi/TextID">7a21c3c8b3c311e1cc8478e3b50a88fe</xsd:appinfo>
                                <xsd:documentation/>
                            </xsd:annotation>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="AmountDayRequired" type="p7:Count" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21c3cab3c311e1b2cb78e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="HomeDelivery" type="p7:Count" minOccurs="0" form="qualified">
                <xsd:annotation>
                    <xsd:appinfo source="http://sap.com/xi/TextID">7a21c3cbb3c311e1a63978e3b50a88fe</xsd:appinfo>
                    <xsd:documentation/>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:group>
</xsd:schema>

ExportXMLSchema2.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://company.org/mail/global/datatypes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://company.org/mail/global/datatypes">
    <xsd:simpleType name="LanguageCode">
        <xsd:restriction base="xsd:language">
            <xsd:minLength value="2"/>
            <xsd:maxLength value="9"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="DayPart.Content">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Part of the day</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="10"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="TeamID">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic object for Team IDs (Used for ERECRUIT)</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="8"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="DescriptionHR">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic description datatype used for HR objects</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="40"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="AreaID">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic object for Area IDs (Used for ERECRUIT)</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="8"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="StreetNameHR">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic Streetname datatype used for HR objects (40 pos.)</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="40"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="Count">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic object for Count (Used by ERECRUIT)</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="1"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="TemporaryWorkerType">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Temporary Worker (Tijdelijke hulpkracht (THK): N, K of J); TNT specific</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="1"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="JobPositionPostingID">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic object for JobPosting IDs (Used for ERECRUIT)</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="8"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="PostalCode">
        <xsd:restriction base="xsd:token">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="10"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="Hours">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Generic datatype for hours</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:int">
            <xsd:maxInclusive value="2"/>
            <xsd:minInclusive value="1"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="PublicationFunctionID">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">PublicationFunctionID for ERECRUIT</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:token">
            <xsd:maxLength value="3"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="City">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Cityname TNT</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:minLength value="1"/>
            <xsd:maxLength value="60"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="DayOfWeek.Content">
        <xsd:annotation>
            <xsd:documentation xml:lang="EN">Description day of the week</xsd:documentation>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:maxLength value="10"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:complexType name="DayPart">
        <xsd:simpleContent>
            <xsd:extension base="DayPart.Content">
                <xsd:attribute name="languageCode" type="LanguageCode"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
    <xsd:complexType name="DayOfWeek">
        <xsd:simpleContent>
            <xsd:extension base="DayOfWeek.Content">
                <xsd:attribute name="languageCode" type="LanguageCode"/>
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
</xsd:schema>

I have tried several ways of importing the Service Reference into my project. Adding it as a Service Reference and by using the SVCUTIL to create the class file and import that into my project (basically by overwriting the original Service Reference). When I setup my service and host it locally or on our development server, the service works fine. However, the message I receive (either from the client or messages send by myself using SoapUI) never include the complex type properties.

Example message contains a list of Availabilities as follows:

<n0:Availability>
   <DayOfWeek>MAANDAG</DayOfWeek>
   <DayPart>OCHTEND</DayPart>
</n0:Availability>
<n0:Availability>
   <DayOfWeek>DINSDAG</DayOfWeek>
   <DayPart>OCHTEND</DayPart>
</n0:Availability>
<n0:Availability>
   <DayOfWeek>WOENSDAG</DayOfWeek>
   <DayPart>OCHTEND</DayPart>
</n0:Availability>

(n0 matched the namespace: http://company.org/mail/hrm/JobPublication)

This message validates correctly in SoapUI, but when my service receives the message the values for DayOfWeek and DayPart are null. I do receive three "Availbility" values, so it is partly working.

I've tried generating the class file with SVCUTIL using options like /ImportXmlTypes and/or /Serializer:XmlSerializer, but nothing seems to work. None of the suggestions found on this board seem to have worked for me. Hopefully someone can point out what I've overlooked.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire