从WSDL生成的服务返回不同的WSDL

时间:2009-07-31 09:25:59

标签: c# wcf wsdl datacontract

我已经从提供的WSDL 架构生成了一个WCF服务接口,然后在我的一个WCF服务中实现了该接口,没有任何问题。

[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)
    {

    }

}

奇怪的是,我的新服务的WSDL不符合它生成的WSDL吗?

传递的WSDL 的一部分如何看起来像

的示例
    <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>

这是生成以下界面的服务

    [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;
    }
}

这个simes没关系。这就是我的服务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>

使用简单的anyType元素替换choice元素?而这个问题是假设放在itemfield上的类型(PRPA_MT201302UV02.Patient.patientPerson和PRPA_MT201302UV02.Patient.patientNonPersonLivingSubject)永远不会在客户端代理类中生成?

我尝试从生成服务的提供的WSDL 架构生成代理客户端类,这将创建一个正确的代理客户端,但是当尝试与服务通信时,将会有Datacontract missmatch异常

为什么WSDL架构不相同?

1 个答案:

答案 0 :(得分:0)

看起来您正在使用运营合同而不是合同(接口)标记班级。

此外,如果您使用DataContract / DataMember属性标记了消息,则不会显示。