2016-11-23 56 views
2

我希望我在这里错过了一些非常简单的东西。与父母的孩子关系VB或C消费Web服务#

我有需要更新一个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> 

我已经添加了Web引用到我的项目,并试图消耗ŧ他服务。在尝试将药物与患者联系时遇到错误。

的代码如下显示:

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) 

我陷在试图将药物添加到父类。

任何建议,将不胜感激

回答

0

medadd.Medications是用药元素的集合,所以你必须使用特定的add方法,而不只是分配一个药品单体对药物

它应该像

medadd.Medications.Add(medlist); 

如果药物尚未分配(零),那么你必须创建一个ne执行添加操作

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

,可以产生一些问题是minOccurs = 0对药物的另一件事之前用药w的空单。它应该是minOccurs = 1

+0

嗨,感谢您的反馈,它一直在帮助我。然而,你的最后一行代码对我来说产生了一个错误“(药物治疗)类型列表的值不能转换为Medication(),我希望你能为我提供一个建议。 – Joe

+0

“medadd.Medications”的类型是哪种? – cristallo

+0

medadd.Medications是Medication类型的。问题在于wsdl吗?非常感谢在这方面的帮助:) – Joe