使用父子关系VB或C#的Web服务

时间:2016-11-23 08:34:31

标签: c# xml vb.net wsdl

我希望我在这里遗漏一些非常简单的东西。

我需要使用特定患者所在的药物列表来更新Web服务。我正在发送患者的身份证以及药物清单。我已经获得了以下WSDL

<?xml version="1.0" encoding="UTF-8"?>

-<wsdl:definitions name="GOLDSessionResponseService" 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
xmlns:tns="http://City.health.xxx.au/" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" 
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" 
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" 
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
targetNamespace="http://City.health.xxx.au/">

-<wsdl:types>

-<xs:schema targetNamespace="http://City.health.xxx.au/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

  <xs:import namespace="http://schemas.datacontract.org/2004/07/City.Services.GOLD"/>


  -<xs:element name="SessionCompleted">


    -<xs:complexType>


      -<xs:sequence>

        <xs:element type="q1:SessionCompletionRequest" name="request" xmlns:q1="http://schemas.datacontract.org/2004/07/City.Services.GOLD" nillable="true" minOccurs="0"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>


  -<xs:element name="SessionCompletedResponse">


    -<xs:complexType>


      -<xs:sequence>

        <xs:element type="q2:SessionCompletionResponse" name="SessionCompletedResult" nillable="true" minOccurs="0" xmlns:q2="http://schemas.datacontract.org/2004/07/City.Services.GOLD"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>


  -<xs:element name="UpdateMedications">


    -<xs:complexType>


      -<xs:sequence>

        <xs:element type="q3:UpdateMedicationsRequest" name="request" nillable="true" minOccurs="0" xmlns:q3="http://schemas.datacontract.org/2004/07/City.Services.GOLD"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>


  -<xs:element name="UpdateMedicationsResponse">


    -<xs:complexType>


      -<xs:sequence>

        <xs:element type="q4:UpdateMedicationsResponse" name="UpdateMedicationsResult" nillable="true" minOccurs="0" xmlns:q4="http://schemas.datacontract.org/2004/07/City.Services.GOLD"/>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

</xs:schema>


-<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified">

  <xs:element type="xs:anyType" name="anyType" nillable="true"/>

  <xs:element type="xs:anyURI" name="anyURI" nillable="true"/>

  <xs:element type="xs:base64Binary" name="base64Binary" nillable="true"/>

  <xs:element type="xs:boolean" name="boolean" nillable="true"/>

  <xs:element type="xs:byte" name="byte" nillable="true"/>

  <xs:element type="xs:dateTime" name="dateTime" nillable="true"/>

  <xs:element type="xs:decimal" name="decimal" nillable="true"/>

  <xs:element type="xs:double" name="double" nillable="true"/>

  <xs:element type="xs:float" name="float" nillable="true"/>

  <xs:element type="xs:int" name="int" nillable="true"/>

  <xs:element type="xs:long" name="long" nillable="true"/>

  <xs:element type="xs:QName" name="QName" nillable="true"/>

  <xs:element type="xs:short" name="short" nillable="true"/>

  <xs:element type="xs:string" name="string" nillable="true"/>

  <xs:element type="xs:unsignedByte" name="unsignedByte" nillable="true"/>

  <xs:element type="xs:unsignedInt" name="unsignedInt" nillable="true"/>

  <xs:element type="xs:unsignedLong" name="unsignedLong" nillable="true"/>

  <xs:element type="xs:unsignedShort" name="unsignedShort" nillable="true"/>

  <xs:element type="tns:char" name="char" nillable="true"/>


  -<xs:simpleType name="char">

    <xs:restriction base="xs:int"/>

  </xs:simpleType>

  <xs:element type="tns:duration" name="duration" nillable="true"/>


  -<xs:simpleType name="duration">


    -<xs:restriction base="xs:duration">

      <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>

      <xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>

      <xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>

    </xs:restriction>

  </xs:simpleType>

  <xs:element type="tns:guid" name="guid" nillable="true"/>


  -<xs:simpleType name="guid">


    -<xs:restriction base="xs:string">

      <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>

    </xs:restriction>

  </xs:simpleType>

  <xs:attribute type="xs:QName" name="FactoryType"/>

  <xs:attribute type="xs:ID" name="Id"/>

  <xs:attribute type="xs:IDREF" name="Ref"/>

</xs:schema>


-<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/City.Services.GOLD" targetNamespace="http://schemas.datacontract.org/2004/07/City.Services.GOLD" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">


  -<xs:complexType name="SessionCompletionRequest">


    -<xs:sequence>

      <xs:element type="xs:dateTime" name="AppointmentDateTime" minOccurs="0"/>

      <xs:element type="xs:dateTime" name="NextAppointmentDateTime" minOccurs="0"/>

      <xs:element type="xs:int" name="PatientId" minOccurs="0"/>

      <xs:element type="xs:string" name="SessionLetter" nillable="true" minOccurs="0"/>

      <xs:element type="xs:int" name="SessionNumber" minOccurs="0"/>

      <xs:element type="xs:string" name="Status" nillable="true" minOccurs="0"/>

    </xs:sequence>

  </xs:complexType>

  <xs:element type="tns:SessionCompletionRequest" name="SessionCompletionRequest" nillable="true"/>


  -<xs:complexType name="SessionCompletionResponse">


    -<xs:sequence>

      <xs:element type="xs:string" name="ErrorMessage" nillable="true" minOccurs="0"/>

      <xs:element type="xs:boolean" name="Success" minOccurs="0"/>

    </xs:sequence>

  </xs:complexType>

  <xs:element type="tns:SessionCompletionResponse" name="SessionCompletionResponse" nillable="true"/>


  -<xs:complexType name="UpdateMedicationsRequest">


    -<xs:sequence>

      <xs:element type="tns:Medication" name="Medications" nillable="true" minOccurs="0"/>

      <xs:element type="xs:int" name="PatientId" minOccurs="0"/>

    </xs:sequence>

  </xs:complexType>

  <xs:element type="tns:UpdateMedicationsRequest" name="UpdateMedicationsRequest" nillable="true"/>


  -<xs:complexType name="Medication">


    -<xs:sequence>

      <xs:element type="xs:string" name="BrandName" nillable="true" minOccurs="0"/>

      <xs:element type="xs:string" name="Generic" nillable="true" minOccurs="0"/>

    </xs:sequence>

  </xs:complexType>

  <xs:element type="tns:Medication" name="Medication" nillable="true"/>


  -<xs:complexType name="UpdateMedicationsResponse">


    -<xs:sequence>

      <xs:element type="xs:string" name="ErrorMessage" nillable="true" minOccurs="0"/>

      <xs:element type="xs:boolean" name="Success" minOccurs="0"/>

    </xs:sequence>

  </xs:complexType>

  <xs:element type="tns:UpdateMedicationsResponse" name="UpdateMedicationsResponse" nillable="true"/>

</xs:schema>

-<wsdl:message name="IGOLDSessionResponseService_SessionCompleted_InputMessage">

    <wsdl:part name="parameters" element="tns:SessionCompleted"/>

</wsdl:message>


-<wsdl:message name="IGOLDSessionResponseService_SessionCompleted_OutputMessage">

    <wsdl:part name="parameters" element="tns:SessionCompletedResponse"/>

</wsdl:message>


-<wsdl:message name="IGOLDSessionResponseService_UpdateMedications_InputMessage">

    <wsdl:part name="parameters" element="tns:UpdateMedications"/>

</wsdl:message>


-<wsdl:message name="IGOLDSessionResponseService_UpdateMedications_OutputMessage">

    <wsdl:part name="parameters" element="tns:UpdateMedicationsResponse"/>

</wsdl:message>


-<wsdl:portType name="IGOLDSessionResponseService">


-<wsdl:operation name="SessionCompleted">

  <wsdl:input message="tns:IGOLDSessionResponseService_SessionCompleted_InputMessage" wsaw:Action="http://City.health.xxx.au/IGOLDSessionResponseService/SessionCompleted"/>

  <wsdl:output message="tns:IGOLDSessionResponseService_SessionCompleted_OutputMessage" wsaw:Action="http://City.health.xxx.au/IGOLDSessionResponseService/SessionCompletedResponse"/>

</wsdl:operation>


-<wsdl:operation name="UpdateMedications">

  <wsdl:input message="tns:IGOLDSessionResponseService_UpdateMedications_InputMessage" wsaw:Action="http://City.health.xxx.au/IGOLDSessionResponseService/UpdateMedications"/>

  <wsdl:output message="tns:IGOLDSessionResponseService_UpdateMedications_OutputMessage" wsaw:Action="http://City.health.xxx.au/IGOLDSessionResponseService/UpdateMedicationsResponse"/>

</wsdl:operation>

-<wsdl:binding type="tns:IGOLDSessionResponseService" name="BasicHttpBinding_IGOLDSessionResponseService">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>


-<wsdl:operation name="SessionCompleted">

  <soap:operation style="document" soapAction="http://City.health.xxx.au/IGOLDSessionResponseService/SessionCompleted"/>


  -<wsdl:input>

    <soap:body use="literal"/>

  </wsdl:input>


  -<wsdl:output>

    <soap:body use="literal"/>

  </wsdl:output>

</wsdl:operation>


-<wsdl:operation name="UpdateMedications">

  <soap:operation style="document" soapAction="http://City.health.xxx.au/IGOLDSessionResponseService/UpdateMedications"/>


  -<wsdl:input>

    <soap:body use="literal"/>

  </wsdl:input>


  -<wsdl:output>

    <soap:body use="literal"/>

  </wsdl:output>

</wsdl:operation>

</wsdl:binding>


-<wsdl:service name="GOLDSessionResponseService">


-<wsdl:port name="BasicHttpBinding_IGOLDSessionResponseService" binding="tns:BasicHttpBinding_IGOLDSessionResponseService">

  <soap:address location="http://services.City.simient.com/GOLD/GOLDSessionResponseService.svc"/>

</wsdl:port>

我已将WebReference添加到我的项目中并尝试使用这些服务。我在尝试将药物与药物联系时遇到错误。

代码显示如下:

Dim medadd As Services.UpdateMedicationsRequest = New Services.UpdateMedicationsRequest()
Dim medresponse As Services.UpdateMedicationsResponse = New Services.UpdateMedicationsResponse()

Dim medlist As Medication = New Medication()


medadd.PatientId = CInt(patientid)
medadd.PatientIdSpecified = True
medlist.BrandName = "testbrand"
medlist.Generic = "testgeneric"


medadd.Medications = medlist??????


medresponse = client.UpdateMedications(medadd)

我在尝试将药物添加到父类时遇到困难。

非常感谢任何建议

1 个答案:

答案 0 :(得分:0)

medadd.Medications是Medication元素的集合,因此您必须使用特定的添加方法,而不仅仅是将药物元素分配给药物

它应该像

medadd.Medications.Add(medlist);

如果尚未分配药物(零),则必须在执行添加操作之前创建新的药物清单

Dim medications As New List(Of Medication)();
medications.Add(medlist);
medadd.Medications = medications;

可能产生某些问题的另一件事是药物的minOccurs = 0。它应该是minOccurs = 1