0

我有一个 ac# 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,并循环通过它以从节点中获取相关数据?

4

0 回答 0