我已经从交付的 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;
}
}
这没问题。这就是我的服务 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 元素?问题在于客户端代理类中永远不会生成假定放置在 itemfield 上的类型(PRPA_MT201302UV02.Patient.patientPerson 和 PRPA_MT201302UV02.Patient.patientNonPersonLivingSubject)?
我试图从生成服务的交付的 WSDL模式生成代理客户端类,这将创建一个正确的代理客户端,但是在尝试与服务通信时会出现 Datacontract 不匹配异常
为什么 WSDL 模式不一样?