簡體   English   中英

使用具有父子關系VB或C#的Web服務

[英]Consuming a web service with a parent child relationship VB or C#

我希望我在這里錯過了一些非常簡單的事情。

我需要使用特定患者正在使用的葯物清單來更新Web服務。 我正在發送患者的ID以及葯物清單。 已為我提供以下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添加到我的項目中,並嘗試使用這些服務。 嘗試將葯物鏈接到患者ID時遇到錯誤。

代碼如下所示:

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)

我被困在嘗試將葯物添加到家長班上。

我們歡迎所有的建議

medadd.Medications是葯物元素的集合,因此您必須使用特定的添加方法,而不僅僅是將葯物元素分配給葯物

它應該像

medadd.Medications.Add(medlist);

如果尚未分配葯物(無),則必須在執行添加操作之前創建新的葯物空白列表

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

可能產生問題的另一件事是葯物的minOccurs = 0 應該是minOccurs = 1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM