![](/img/trans.png)
[英]Consuming a Webservice (WSDL) using monodevelop C# on 4.0 on Windows 7 Pro
[英]consuming webservice with c# from wsdl (noob)
我正在尝试编写一些C#代码来调用Web服务。 我正在尝试验证用户(authenticateToNCIDv2Request),然后查看结果(authenticateToNCIDv2Result)。 基于wsdl,我不了解如何完成此操作。
我的代码(错了)如下所示:
SingleSignOn.authenticateToNCIDv2Request request = new SingleSignOn.authenticateToNCIDv2Request();
request.AppID = "1234";
request.AppPassword = "appPW";
request.UserID = "testUser";
request.UserPassword = "userPW";
request = new authenticateToNCIDv2Request1(request).authenticateToNCIDv2Request;
SingleSignOnTest.SingleSignOn.authenticateToNCIDv2Response resp = new SingleSignOn.authenticateToNCIDv2Response();
SingleSignOn.authenticateToNCIDv2Result rslt = resp.authenticateToNCIDv2Result;
string y = rslt.Error;
SingleSignOn.Message[] msg = rslt.MessageArray;
wsdl(删除了简短的部分)如下:
<xs:element name="authenticateToNCIDv2Response" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element ref="ncidng:authenticateToNCIDv2Result" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="authenticateToNCIDv2Result" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element maxOccurs="1" minOccurs="0" ref="ncidng:MessageArray" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Error" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="MessageArray" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element maxOccurs="unbounded" ref="ncidng:Message" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Message" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType mixed="true" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attribute name="code" type="xs:NMTOKEN" use="required" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</xs:complexType>
</xs:element>
<xs:group name="userinfogroup" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element maxOccurs="1" minOccurs="1" name="User_DN" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="User_ID" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Personal_Title" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="First_Name" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Middle_Initial" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="Last_Name" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="Full_Name" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Suffix" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="User_Type" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Employee_Type" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="GUID" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Account_Expiration_Date" type="xs:dateTime" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Login_Disabled" type="xs:boolean" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Locked_by_Intruder" type="xs:boolean" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Password_Expiration_Date" type="xs:dateTime" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Second_Factor_Role" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="Account_Status" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Migration_Status" type="xs:boolean" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Business_Phone" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Business_Phone_Ext" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="1" name="eMail" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Street" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Address_Line2" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="City" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="State" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="Zip_Code" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" name="CR_Config" type="xs:boolean" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" ref="ncidng:Member_of_OrganizationArray" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" ref="ncidng:Member_of_DivisionArray" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<xs:element maxOccurs="1" minOccurs="0" ref="ncidng:Member_of_SectionArray" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</xs:sequence>
</xs:group>
<xs:element name="NCIDWebServiceException" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="reason" nillable="true" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</xs:sequence>
</xs:complexType>
</xs:element>
提前致谢!
您如何尝试做到这一点? 传统上是这样的
//initialize the client
SingleSignOn client = new SingleSignOnClient();
//initialize the request
authenticateToNCIDv2Request request = new authenticateToNCIDv2Request();
//fill the request
request.AppID = "1234";
request.AppPassword = "appPW";
request.UserID = "testUser";
request.UserPassword = "userPW";
//initialize the response and fill it with response from method
authenticateToNCIDv2Response response = client.authenticateToNCIDv2(request);
从这里开始,您解析响应。 请注意,我没有深入研究您的wsdl以查看我的代码是否正确
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.