views:

405

answers:

2

I have generated a WCF service interface from a delivered WSDL schema, this interface have then been implemented in one of my WCF services without any problems.

[ServiceBehavior(Name = "HL7Service", Namespace = "urn:hl7-org:v3")]
[ServiceContract(Namespace = "urn:hl7-org:v3", Name = "HL7Service", SessionMode = SessionMode.Allowed)]
public class HL7Service : IPatientRegistryQueryTracker_Binding
{


    [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "PRPA_IN201302NO_Operation")]
    public PRPA_IN201302NOResponse PRPA_IN201302NO_Operation(PRPA_IN201302NO request)
    {

    }

    [OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "PRPA_IN201304NO_Operation")]
    public PRPA_IN201304NOResponse PRPA_IN201304NO_Operation(PRPA_IN201304NO request)
    {

    }

}

The strange part is that the WSDL from my new service do not comply to the WSDL it was generated from?

Example on how a part of the delivered WSDL lookt like

    <xs:complexType name="PRPA_MT201302UV02.Patient">
 <xs:sequence>
  <xs:group ref="InfrastructureRootElements"/>
  <xs:element name="id" type="PRPA_MT201302UV02.Patient.id" maxOccurs="unbounded"/>
  <xs:element name="addr" type="AD" minOccurs="0" maxOccurs="unbounded"/>
  <xs:element name="telecom" type="TEL" minOccurs="0" maxOccurs="unbounded"/>
  <xs:element name="statusCode" type="PRPA_MT201302UV02.Patient.statusCode"/>
  <xs:element name="effectiveTime" type="IVL_TS" minOccurs="0"/>
  <xs:element name="confidentialityCode" type="CE" minOccurs="0" maxOccurs="unbounded"/>
  <xs:element name="veryImportantPersonCode" type="CE" minOccurs="0"/>
  <xs:choice>
   <xs:element name="patientPerson" type="PRPA_MT201302UV02.Patient.patientPerson" nillable="true"/>
   <xs:element name="patientNonPersonLivingSubject" type="PRPA_MT201302UV02.Patient.patientNonPersonLivingSubject" nillable="true"/>
  </xs:choice>
  <xs:element name="providerOrganization" type="COCT_MT150003UV03.Organization" nillable="true" minOccurs="0"/>
  <xs:element name="subjectOf" type="PRPA_MT201302UV02.Subject4" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
  <xs:element name="coveredPartyOf" type="PRPA_MT201302UV02.CoveredParty" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
 </xs:sequence>
 <xs:attributeGroup ref="InfrastructureRootAttributes"/>
 <xs:attribute name="nullFlavor" type="NullFlavor" use="optional"/>
 <xs:attribute name="classCode" type="RoleClass" use="required" fixed="PAT"/>
</xs:complexType>

This is generated to the following interface to my service

    [System.Xml.Serialization.XmlElementAttribute("patientNonPersonLivingSubject", typeof(PRPA_MT201302UV02PatientpatientNonPersonLivingSubject), IsNullable=true)]
[System.Xml.Serialization.XmlElementAttribute("patientPerson", typeof(PRPA_MT201302UV02PatientpatientPerson), IsNullable=true)]
public object Item {
    get {
        return this.itemField;
    }
    set {
        this.itemField = value;
    }
}

This simes okay. This is how the same part looks from my service WSDL.

<xs:complexType name="PRPA_MT201302UV02Patient">
−
<xs:sequence>
 <xs:element name="addrField" nillable="true" type="tns:ArrayOfAD"/>
 <xs:element name="classCodeField" nillable="true" type="xs:string"/>
 <xs:element name="confidentialityCodeField" nillable="true" type="tns:ArrayOfCE"/>
 <xs:element name="coveredPartyOfField" nillable="true" type="tns:ArrayOfPRPA_MT201302UV02CoveredParty"/>
 <xs:element name="effectiveTimeField" nillable="true" type="tns:IVL_TS"/>
 <xs:element name="idField" nillable="true" type="tns:ArrayOfPRPA_MT201302UV02Patientid"/>
 <xs:element name="itemField" nillable="true" type="xs:anyType"/>
 <xs:element name="nullFlavorField" nillable="true" type="xs:string"/>
 <xs:element name="providerOrganizationField" nillable="true" type="tns:COCT_MT150003UV03Organization"/>
 <xs:element name="realmCodeField" nillable="true" type="tns:ArrayOfCS"/>
 <xs:element name="statusCodeField" nillable="true" type="tns:PRPA_MT201302UV02PatientstatusCode"/>
 <xs:element name="subjectOfField" nillable="true" type="tns:ArrayOfPRPA_MT201302UV02Subject4"/>
 <xs:element name="telecomField" nillable="true" type="tns:ArrayOfTEL"/>
 <xs:element name="templateIdField" nillable="true" type="tns:ArrayOfII"/>
 <xs:element name="typeIdField" nillable="true" type="tns:II"/>
 <xs:element name="veryImportantPersonCodeField" nillable="true" type="tns:CE"/>
</xs:sequence>

The choice element are replaced with a simple anyType element? And the problem with this is that the types(PRPA_MT201302UV02.Patient.patientPerson and PRPA_MT201302UV02.Patient.patientNonPersonLivingSubject) that are suppose to be placed on itemfield is never generated in the client proxy class?

I have tried to generate the proxy client classes from the delivered WSDL schema that the service are generated from and this will create a correct proxy client, BUT when trying to communicate with the service there will be an Datacontract missmatch exception

Why is not the WSDL schema the same?

A: 

Looks like you are marking the class with the operational contract instead of the contract (Interface).

Also you do not show if you have marked your messages with DataContract / DataMember attribute.

Shiraz Bhaiji
A: 

Thanks!

Can you pleas provide an example of how I should decorate the service class with the correct contract(interface)?

The messages are generated with the service interface and the generated code looks like this :

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.312")]

[System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:hl7-org:v3")] public partial class PRPA_IN201302NO : PRPA_IN201302UV02MCCI_MT000100UV01Message {

private string iTSVersionField;

public PRPA_IN201302NO() {
    this.iTSVersionField = "XML_1.0";
}

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string ITSVersion {
    get {
        return this.iTSVersionField;
    }
    set {
        this.iTSVersionField = value;
    }
}

}

EDIT:

Hi,

I have no made the following changes on your request :

  1. Moved ServiceContract and Operationscontract attribute(s) from HL7Service to the interface IPatientRegistryQueryTracker_Binding
  2. Changed the ServiceContract(name) from HL7Service to IPatientRegistryQueryTracker_Binding
  3. Added namespace to the generated interface to be able to locate the interface from the web.config(endpoint)
  4. Changed the endpoint contract from HL7Service to IPatientRegistryQueryTracker_Binding

This did however not work, the itemfield it still set to AnyType in the service WSDL.

I have no clue why this is happening?