MarilynJ

I am trying to take the output array from a web service and move it into a datatable using c#. I have a web reference to the service as well as a proxy. The WSDL is:

< xml version="1.0" encoding="utf-8" >
<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>
<GetSitesForContactResponse xmlns=http://companyA.com/pms>
<GetSitesForContactResult>
<SiteResult>
<SiteId>string</SiteId>
<SiteName>string</SiteName>
<Address>string</Address>
<Address2>string</Address2>
<City>string</City>
<State>string</State>
<Zipcode>string</Zipcode>
<Country>string</Country>
<IsPrimarySite>boolean</IsPrimarySite>
</SiteResult>
<SiteResult>
<SiteId>string</SiteId>
<SiteName>string</SiteName>
<Address>string</Address>
<Address2>string</Address2>
<City>string</City>
<State>string</State>
<Zipcode>string</Zipcode>
<Country>string</Country>
<IsPrimarySite>boolean</IsPrimarySite>
</SiteResult>
</GetSitesForContactResult>
</GetSitesForContactResponse>
</soap:Body>
</soap:Envelope>

I thought I could do this without having to parse the xml by traversing nodes but I can't seem to get it right. Any thoughts on the best way to accomplish this

Thanks.



Re: ASMX Web Services and XML Serialization How to read array returned from Web Service method

Elena Kharitidi

You should not have to parse the xml. Generated proxy should deserialize the message, and allow you strongly-typed access to the return types. One possibility is that the message you posted does not conform to the wsdl, please post the service description of the service (wsdl file)

Thanks,

elena





Re: ASMX Web Services and XML Serialization How to read array returned from Web Service method

MarilynJ

Here's the WSDL.  I want to take the  ArrayOfSiteResult and move it into a dataTable using c#.

 < xml version="1.0" encoding="utf-8" >

- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns=http://myCompany.com/pms
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace=http://myCompany.com/pms xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Web Service</wsdl:documentation>
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace=http://myCompany.com/pms>
- <s:element name="IsContactValid">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="email" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="IsContactValidResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="IsContactValidResult" type="tns:ContactValidResult" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="ContactValidResult">
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="IsValid" type="s:boolean" />
  <s:element minOccurs="1" maxOccurs="1" name="ContactPrimaryKey" type="s:int" />
  </s:sequence>
  </s:complexType>
- <s:element name="GetContact">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="GetContactResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="GetContactResult" type="tns:ContactResult" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="ContactResult">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="LastName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Phone" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Zipcode" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
  </s:sequence>
  </s:complexType>
- <s:element name="GetSitesForContact">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="GetSitesForContactResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="GetSitesForContactResult" type="tns:ArrayOfSiteResult" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="ArrayOfSiteResult">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="unbounded" name="SiteResult" nillable="true" type="tns:SiteResult" />
  </s:sequence>
  </s:complexType>
- <s:complexType name="SiteResult">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Zipcode" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="IsPrimarySite" type="s:boolean" />
  </s:sequence>
  </s:complexType>
- <s:element name="QueryCases">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
  <s:element minOccurs="1" maxOccurs="1" name="CreatedAfter" type="s:dateTime" />
  <s:element minOccurs="1" maxOccurs="1" name="CreatedBefore" type="s:dateTime" />
  <s:element minOccurs="0" maxOccurs="1" name="Condition" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="ForThisContactOnly" type="s:boolean" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteIDs" type="tns:ArrayOfString" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="ArrayOfString">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
  </s:sequence>
  </s:complexType>
- <s:element name="QueryCasesResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="QueryCasesResult" type="tns:ArrayOfCaseQueryResult" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="ArrayOfCaseQueryResult">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="unbounded" name="CaseQueryResult" nillable="true" type="tns:CaseQueryResult" />
  </s:sequence>
  </s:complexType>
- <s:complexType name="CaseQueryResult">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="IdNumber" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Condition" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="CaseType" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="CreateDate" type="s:dateTime" />
  <s:element minOccurs="0" maxOccurs="1" name="ContactFirstName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="ContactLastName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="PartNumber" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="PartDescription" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SerialNumber" type="s:string" />
  </s:sequence>
  </s:complexType>
- <s:element name="GetCaseDetails">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="caseIdNumber" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="GetCaseDetailsResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="GetCaseDetailsResult" type="tns:CaseDetailResult" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:complexType name="CaseDetailResult">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="IdNumber" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Condition" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="CaseType" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="CreateDate" type="s:dateTime" />
  <s:element minOccurs="0" maxOccurs="1" name="Severity" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="CurrentPhone" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="CloseDate" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="OwnerFirstName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="OwnerLastName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="ContactFirstName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="ContactLastName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="ContactPhone" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Zipcode" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="PartNumber" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="PartDescription" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="serialNumber" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="ActivityRecords" type="tns:ArrayOfActivityRecord" />
  </s:sequence>
  </s:complexType>
- <s:complexType name="ArrayOfActivityRecord">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="unbounded" name="ActivityRecord" nillable="true" type="tns:ActivityRecord" />
  </s:sequence>
  </s:complexType>
- <s:complexType name="ActivityRecord">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Activity" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="ActivityDate" type="s:dateTime" />
  <s:element minOccurs="0" maxOccurs="1" name="EmployeeFirstName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="EmployeeLastName" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="ActivitySummary" type="s:string" />
  <s:element minOccurs="0" maxOccurs="1" name="Notes" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:schema>
  </wsdl:types>
- <wsdl:message name="IsContactValidSoapIn">
  <wsdl:part name="parameters" element="tns:IsContactValid" />
  </wsdl:message>
- <wsdl:message name="IsContactValidSoapOut">
  <wsdl:part name="parameters" element="tns:IsContactValidResponse" />
  </wsdl:message>
- <wsdl:message name="GetContactSoapIn">
  <wsdl:part name="parameters" element="tns:GetContact" />
  </wsdl:message>
- <wsdl:message name="GetContactSoapOut">
  <wsdl:part name="parameters" element="tns:GetContactResponse" />
  </wsdl:message>
- <wsdl:message name="GetSitesForContactSoapIn">
  <wsdl:part name="parameters" element="tns:GetSitesForContact" />
  </wsdl:message>
- <wsdl:message name="GetSitesForContactSoapOut">
  <wsdl:part name="parameters" element="tns:GetSitesForContactResponse" />
  </wsdl:message>
- <wsdl:message name="QueryCasesSoapIn">
  <wsdl:part name="parameters" element="tns:QueryCases" />
  </wsdl:message>
- <wsdl:message name="QueryCasesSoapOut">
  <wsdl:part name="parameters" element="tns:QueryCasesResponse" />
  </wsdl:message>
- <wsdl:message name="GetCaseDetailsSoapIn">
  <wsdl:part name="parameters" element="tns:GetCaseDetails" />
  </wsdl:message>
- <wsdl:message name="GetCaseDetailsSoapOut">
  <wsdl:part name="parameters" element="tns:GetCaseDetailsResponse" />
  </wsdl:message>
- <wsdl:portType name="ServiceSoap">
- <wsdl:operation name="IsContactValid">
  <wsdl:input message="tns:IsContactValidSoapIn" />
  <wsdl:output message="tns:IsContactValidSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="GetContact">
  <wsdl:input message="tns:GetContactSoapIn" />
  <wsdl:output message="tns:GetContactSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="GetSitesForContact">
  <wsdl:input message="tns:GetSitesForContactSoapIn" />
  <wsdl:output message="tns:GetSitesForContactSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="QueryCases">
  <wsdl:input message="tns:QueryCasesSoapIn" />
  <wsdl:output message="tns:QueryCasesSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="GetCaseDetails">
  <wsdl:input message="tns:GetCaseDetailsSoapIn" />
  <wsdl:output message="tns:GetCaseDetailsSoapOut" />
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="IsContactValid">
  <soap:operation soapAction=http://myCompany.com/pms/IsContactValid style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="GetContact">
  <soap:operation soapAction=http://myCompany.com/pms/GetContact style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="GetSitesForContact">
  <soap:operation soapAction=http://myCompany.com/pms/GetSitesForContact style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="QueryCases">
  <soap:operation soapAction=http://myCompany.com/pms/QueryCases style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="GetCaseDetails">
  <soap:operation soapAction=http://myCompany.com/pms/GetCaseDetails style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="IsContactValid">
  <soap12:operation soapAction=http://myCompany.com/pms/IsContactValid style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="GetContact">
  <soap12:operation soapAction="http://myCompany.com/pms/clarify/eSupport/GetContact" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="GetSitesForContact">
  <soap12:operation soapAction=http://myCompany.com/pms/GetSitesForContact style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="QueryCases">
  <soap12:operation soapAction=http://myCompany.com/pms/QueryCases style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="GetCaseDetails">
  <soap12:operation soapAction=http://myCompany.com/pms/GetCaseDetails style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="Service">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Web Service</wsdl:documentation>
- <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
  <soap:address location=http://myCompany.com/Service.asmx />
  </wsdl:port>
- <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
  <soap12:address location=http://myCompany.com/Service.asmx />
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>




Re: ASMX Web Services and XML Serialization How to read array returned from Web Service method

Elena Kharitidi

The namespace of the response does not match the namespace used for the user types in the wsdl

response namespace: <GetSitesForContactResponse xmlns="http://companyA.com/pms">

namespace used in wsdl: <s:schema elementFormDefault="qualified" targetNamespace="http://myCompany.com/pms">

they have to match

By the way both instance xml and wsld you provided are missing some important quotes around namespace and soapAction values.

ou can use wsdl.exe or Add Web Reference in VS to generate a client proxy allowing you to make the call to the

You can use wsdl.exe or Add Web Reference in VS to generate a client proxy allowing you to make the call to the GetSitesForContract method to get the instance of the SiteResult[], then you can iterate over the array and populate your DataTable.

Here is the fixed up wsdl, try running the wsdl.exe on it, and take a look at the generated class (service) and the method (public SiteResult[] GetSitesForContact(int contactPrimaryKey) {..})

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://myCompany.com/pms" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://myCompany.com/pms" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Web Service</wsdl:documentation>
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://myCompany.com/pms">
<s:element name="IsContactValid">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="email" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="IsContactValidResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="IsContactValidResult" type="tns:ContactValidResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ContactValidResult">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="IsValid" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" name="ContactPrimaryKey" type="s:int" />
</s:sequence>
</s:complexType>
<s:element name="GetContact">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetContactResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetContactResult" type="tns:ContactResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ContactResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="LastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Phone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Zipcode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="GetSitesForContact">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetSitesForContactResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetSitesForContactResult" type="tns:ArrayOfSiteResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfSiteResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="SiteResult" nillable="true" type="tns:SiteResult" />
</s:sequence>
</s:complexType>
<s:complexType name="SiteResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Zipcode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="IsPrimarySite" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:element name="QueryCases">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="CreatedAfter" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="CreatedBefore" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="Condition" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ForThisContactOnly" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="SiteIDs" type="tns:ArrayOfString" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfString">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="QueryCasesResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="QueryCasesResult" type="tns:ArrayOfCaseQueryResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfCaseQueryResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="CaseQueryResult" nillable="true" type="tns:CaseQueryResult" />
</s:sequence>
</s:complexType>
<s:complexType name="CaseQueryResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="IdNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Condition" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CaseType" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="CreateDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="ContactFirstName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ContactLastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PartNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PartDescription" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SerialNumber" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="GetCaseDetails">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="caseIdNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="contactPrimaryKey" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetCaseDetailsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCaseDetailsResult" type="tns:CaseDetailResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="CaseDetailResult">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="IdNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Condition" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CaseType" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="CreateDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="Severity" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CurrentPhone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CloseDate" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="OwnerFirstName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="OwnerLastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ContactFirstName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ContactLastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ContactPhone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Zipcode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PartNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PartDescription" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="serialNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ActivityRecords" type="tns:ArrayOfActivityRecord" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfActivityRecord">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="ActivityRecord" nillable="true" type="tns:ActivityRecord" />
</s:sequence>
</s:complexType>
<s:complexType name="ActivityRecord">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Activity" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ActivityDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="EmployeeFirstName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmployeeLastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ActivitySummary" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Notes" type="s:string" />
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="IsContactValidSoapIn">
<wsdl:part name="parameters" element="tns:IsContactValid" />
</wsdl:message>
<wsdl:message name="IsContactValidSoapOut">
<wsdl:part name="parameters" element="tns:IsContactValidResponse" />
</wsdl:message>
<wsdl:message name="GetContactSoapIn">
<wsdl:part name="parameters" element="tns:GetContact" />
</wsdl:message>
<wsdl:message name="GetContactSoapOut">
<wsdl:part name="parameters" element="tns:GetContactResponse" />
</wsdl:message>
<wsdl:message name="GetSitesForContactSoapIn">
<wsdl:part name="parameters" element="tns:GetSitesForContact" />
</wsdl:message>
<wsdl:message name="GetSitesForContactSoapOut">
<wsdl:part name="parameters" element="tns:GetSitesForContactResponse" />
</wsdl:message>
<wsdl:message name="QueryCasesSoapIn">
<wsdl:part name="parameters" element="tns:QueryCases" />
</wsdl:message>
<wsdl:message name="QueryCasesSoapOut">
<wsdl:part name="parameters" element="tns:QueryCasesResponse" />
</wsdl:message>
<wsdl:message name="GetCaseDetailsSoapIn">
<wsdl:part name="parameters" element="tns:GetCaseDetails" />
</wsdl:message>
<wsdl:message name="GetCaseDetailsSoapOut">
<wsdl:part name="parameters" element="tns:GetCaseDetailsResponse" />
</wsdl:message>
<wsdl:portType name="ServiceSoap">
<wsdl:operation name="IsContactValid">
<wsdl:input message="tns:IsContactValidSoapIn" />
<wsdl:output message="tns:IsContactValidSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetContact">
<wsdl:input message="tns:GetContactSoapIn" />
<wsdl:output message="tns:GetContactSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetSitesForContact">
<wsdl:input message="tns:GetSitesForContactSoapIn" />
<wsdl:output message="tns:GetSitesForContactSoapOut" />
</wsdl:operation>
<wsdl:operation name="QueryCases">
<wsdl:input message="tns:QueryCasesSoapIn" />
<wsdl:output message="tns:QueryCasesSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetCaseDetails">
<wsdl:input message="tns:GetCaseDetailsSoapIn" />
<wsdl:output message="tns:GetCaseDetailsSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="IsContactValid">
<soap:operation soapAction="http://myCompany.com/pms/IsContactValid" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetContact">
<soap:operation soapAction="http://myCompany.com/pms/GetContact" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetSitesForContact">
<soap:operation soapAction="http://myCompany.com/pms/GetSitesForContact" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="QueryCases">
<soap:operation soapAction="http://myCompany.com/pms/QueryCases" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetCaseDetails">
<soap:operation soapAction="http://myCompany.com/pms/GetCaseDetails" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="IsContactValid">
<soap12:operation soapAction="http://myCompany.com/pms/IsContactValid" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetContact">
<soap12:operation soapAction="http://myCompany.com/pms/clarify/eSupport/GetContact" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetSitesForContact">
<soap12:operation soapAction="http://myCompany.com/pms/GetSitesForContact" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="QueryCases">
<soap12:operation soapAction="http://myCompany.com/pms/QueryCases" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetCaseDetails">
<soap12:operation soapAction="http://myCompany.com/pms/GetCaseDetails" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Web Service</wsdl:documentation>
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address location="http://myCompany.com/Service.asmx" />
</wsdl:port>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address location="http://myCompany.com/Service.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Thanks,

elena





Re: ASMX Web Services and XML Serialization How to read array returned from Web Service method

MarilynJ

Elena

Thanks for your response...but the typo was actually caused by my editing the xml namespaces for the purpose of posting it to this forum. They actually are fine within the real code.

It seems like looping through the array would be so easy but something else is going on here. For instance if I perform the following the loop only goes through once but if I print out the upperbound value it is 4! How can I read the SiteResult[] into an array that only contains the siteId's I get the same results if I use a foreach too. The WS is written in VS2005 while my app is VS2003. Any suggestions are appreciated as this should be a piece of cake! Thanks.

MyService cs = new MyService();

SiteResult[] xdSites = cs.GetSitesForContact(Convert.ToInt16(Session["pkContact"]));

string[] arrayOfSiteIds = null;

for (int i=0; i< xdSites.GetUpperBound(0); i++){

arrayOfSiteIdsIdea = xdSitesIdea.SiteId.ToString();

}