Reputation: 2146
This is quite embarrassing ,tried to find the solution by myself but real lack of knowledge i couldn't able to ,so am posting my question here.
my wcf service return this value when i call my service
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetProcessLocationsResponse xmlns="http://tempuri.org/">
<GetProcessLocationsResult >
<a:ProcessLocationData>
<a:Id>1</a:Id>
<a:Name>IL</a:Name>
</a:ProcessLocationData>
<a:ProcessLocationData>
<a:Id>2</a:Id>
<a:Name>MD</a:Name>
</a:ProcessLocationData>
<a:ProcessLocationData>
<a:Id>3</a:Id>
<a:Name>NY</a:Name>
</a:ProcessLocationData>
</GetProcessLocationsResult>
</GetProcessLocationsResponse>
</s:Body>
</s:Envelope>
in my service class i wrote this method
public Array GetProcessLocations()
{
return this.GetSoapServiceClient().GetProcessLocations().ToArray();
}
public List<ProcessLocationData> GetProcessLocationsOnlyName()
{
return this.GetSoapServiceClient().GetProcessLocations().ToList();
}
i call this service in my xyz.class like below
Array GetProcLocation= new GatewayService().GetProcessLocations();
this return whole object like ID and Name
but i was trying to get only the name by calling the "GetProcessLocationsOnlyName" method
i was trying to do like below
array ProcName= ProcessLocationData.Name
should return all the name in the service like (IL,MD,NY) in the array but i couldn't able to see ProcessLocationData at all.
In another way i was trying to split the array(GetProcLocation) and get only the name and add in to new array ? is that make sense ?
Please some one guide me in to right path.thanks in advance.
Upvotes: 0
Views: 180
Reputation: 863
I am a little confused about your question. I do understand that you want to have 2 service methods, both of them returning an array of ProcessLocationData, one returning the list with id and name (GetProcessLocations) and one returning an array of ProcessLocationData with name only (GetProcessLocationsOnlyName). And your problem is that the client proxy doesn't contain the GetProcessLocationsOnlyName method.
You should make sure that both methods are annotated with OperationContract, otherwise they won't be exposed by your service. You should have this attribute in either your service interface or in service directly. You can see that your service exposes both methods in either wsdl or using the WCF Test Client.
And then you must make sure your client proxy is up to date.
Related to your comment, if you want to return only the name field you have the following options.
My advice is to use the same DataContract and to load only the needed data in the data access method. For example, make a new method GetProcessLocationsName(), that will create your list of ProcessLocationData with only their Name loaded.
Upvotes: 2