2012-07-09 4 views
1

.NET C# 프로젝트에서 아래 WSDL을 사용하여 웹 서비스를 사용하려고합니다.C# 웹 서비스 사용 오류

나는 웹 참조 등을 추가하는 방법 (getPatients)를 호출 시도했지만 항상 오류를 반환했습니다 : (내가 전에 성공적으로 사용했던 동일) 내 코드가 괜찮다고 생각

"MyService.PatientType[] PatientService.getPatients(MyService.getPatients getPatients1)" 
"No overload for method 'getPatients' takes 0 arguments" 

을 하지만 내가 뭔가 잘못하고있을거야 ...

MyService.PatientService ws = new MyService.PatientService(); 
string message = ws.getPatients(); 

누구 아이디어가 있습니까?

감사

WSDL :

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<wsdl:definitions name="patient" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tns="http://www.example.org/patientservice/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:p1="http://www.example.org/patientservice/patient_types/" 
targetNamespace="http://www.example.org/patientservice/"> 
<wsdl:types> 
<xsd:schema targetNamespace="http://www.example.org/patientservice/patient_types/" 
xmlns:tns="http://www.example.org/patientservice/patient_types/"  
xmlns:ns1="http://www.example.org/patient" 
elementFormDefault="qualified"> 

<xsd:complexType name="patientType"> 
<xsd:sequence> 
<xsd:element name="name" type="xsd:string"/> 
<xsd:element name="age" type="xsd:int"/> 
<xsd:element name="ssn" type="xsd:string"/> 
<xsd:element name="pid" type="xsd:int"/> 
</xsd:sequence> 
</xsd:complexType> 

<xsd:element name="getPatients"> 
<xsd:complexType/> 
</xsd:element> 

<xsd:element name="getPatientsResponse"> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element name="patient" type="tns:patientType" maxOccurs="unbounded" minOccurs="0"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element> 

<xsd:element name="getPatient"> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element name="ssn" type="xsd:string" /> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element> 

<xsd:element name="getPatientResponse"> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element name="patient" type="tns:patientType"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element> 

</xsd:schema> 
</wsdl:types> 
<wsdl:message name="getPatientsRequest"> 
<wsdl:part element="p1:getPatients" name="in"/> 
</wsdl:message> 
<wsdl:message name="getPatientsResponse"> 
<wsdl:part element="p1:getPatientsResponse" name="out"/> 
</wsdl:message> 
<wsdl:message name="getPatientRequest"> 
<wsdl:part name="in" element="p1:getPatient"></wsdl:part> 
</wsdl:message> 
<wsdl:message name="getPatientResponse"> 
<wsdl:part name="out" element="p1:getPatientResponse"></wsdl:part> 
</wsdl:message> 
<wsdl:portType name="patient"> 
<wsdl:operation name="getPatients"> 
<wsdl:input message="tns:getPatientsRequest"/> 
<wsdl:output message="tns:getPatientsResponse"/> 
</wsdl:operation> 
<wsdl:operation name="getPatient"> 
<wsdl:input message="tns:getPatientRequest"></wsdl:input> 
<wsdl:output message="tns:getPatientResponse"></wsdl:output> 
</wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="patientSOAP" type="tns:patient"> 
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
<wsdl:operation name="getPatients"> 
<soap:operation style="document" soapAction=""/> 
<wsdl:input name="getPatientsRequest"> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output name="getPatientsResponse"> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
<wsdl:operation name="getPatient"> 
<soap:operation style="document" soapAction=""/> 
<wsdl:input name="getPatientRequest"> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output name="getPatientResponse"> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="PatientService"> 
<wsdl:port binding="tns:patientSOAP" name="PatientSOAPPort"> 
<soap:address location="http://192.168.100.1:8080/patientservice"/> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

답변

1

나는 WSDL에 대한 프록시를 생성했는데이 방법의 getPatients이 매개 변수를 보인다. 일

PatientService ws = new PatientService(); 
getPatients getPatients1 = new getPatients(); 
patientType[] patients = ws.getPatients(getPatients1); 
+0

안녕 알렉스,하지만 늘 문자열로 변환 :

이 시도. 나는 또한 환자 유형을 사용하여 시도했지만 그 didnt 일. 나는 당신이 제안한 것을 시도했다는 것을 확신했다 :) – Developr

+1

당신은 항상 var response = ws.getPatients (getPatient1)와 디버깅을 사용하여 어떤 타입이 리턴 하는지를 볼 수 있었다. – Troy

+1

트로이 (Troy)가 말한 것은 작동하지만 리턴 된 실제 유형을 사용하려는 경우, 올바른 리턴 유형 인 patientType의 배열로 코드를 수정했습니다. –