我有一个c#web应用程序,它有一个简单的任务:使用外部Web服务,并循环返回其返回的xml。
我正在使用这样的网络服务:
WSExternal.SoapHeaderCredentials objHeaderCredentials = new WSExternal.SoapHeaderCredentials();
objHeaderCredentials.UserName = "username";
objHeaderCredentials.Password = "password";
WSExternal.MembershipAuthenticationService objClient = new WSExternal.MembershipAuthenticationService();
objClient.SoapHeaderCredentialsValue = objHeaderCredentials;
我可以像这样调用单个公开的Web方法:
objClient.GetMembershipUserList(false);
如果我通过像SoapUI或XMLSpy这样的客户端访问Web服务,它会像这样返回xml:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetMembershipUserListResponse xmlns="http://namespaceofwebservice">
<GetMembershipUserListResult>
<UserList>
<MembershipUserData>
<id>1</id>
<UserName>userone</UserName>
<PrimaryFirstName>User</PrimaryFirstName>
<PrimaryLastName>One</PrimaryLastName>
<Address>13 MAIN STREET</Address>
<City>ROCHESTER</City>
</MembershipUserData>
<MembershipUserData>
<id>2</id>
<UserName>usertwo</UserName>
<PrimaryFirstName>User</PrimaryFirstName>
<PrimaryLastName>Two</PrimaryLastName>
<Address>15 WEST AVE</Address>
<City>JERSEY CITY</City>
</MembershipUserData>
</UserList>
<Page>0</Page>
</GetMembershipUserListResult>
</GetMembershipUserListResponse>
</soap:Body>
我的问题是,我如何从Web方法“捕获”这个xml,并循环它以从节点中获取相关数据?