Ambiguous class references and type mismatches while consuming web services

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I apologize if this seems simple, but my own research hasnt yielded any usable results yet. I have a project that is consuming several web services. One web service is used to create an object that must be used as a parameter in another web services
method. So something like:
var service1 = new webService1();
var service2 = new webService2();
var parameter = service1.getParameter();
var results = service2.getData(parameter);

The issue is, the class that is created exists in both web services namespaces. So, in the example above, service2 expects a type of service2.parameter, but the only thing I have to pass it is a type of service1.parameter. I can solve the issue of ambiguous
namespaces by aliasing the types in my using statements, but that doesnt solve the issue of the type mismatch. As far as I can tell, the objects should be identical, but I only have a way to create the object in one service, which then is not the correct
type for where it must be used. Not sure what to do, so any help would be appreciated. It should be noted that I dont have any access to modify the web services in any way. Heres some basic code that shows my problem. Thanks in advance.


<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using System;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using ConsoleApplication1.ZLMessageSearchHomeService;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using ConsoleApplication1.ZLMessageSearchQueryHomeService;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using MessageSearchSession = ConsoleApplication1.ZLMessageSearchHomeService.Session;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using MessageQuerySession = ConsoleApplication1.ZLMessageSearchQueryHomeService.Session;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using MessageSearchQuery = ConsoleApplication1.ZLMessageSearchHomeService.SearchQuery;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
using SearchQuery = ConsoleApplication1.ZLMessageSearchQueryHomeService.SearchQuery;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
namespace ConsoleApplication1
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
{
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
class Class1
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
{
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
public void TestServices(string[] args)
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
{
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// Create the service and the session
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
var messageSearchService = new MessageSearchHomeService();
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
var messageSearchSession = new MessageSearchSession();
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// This will return the paramter that I must pass to the service
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
SearchQuery query = GetMessageSearchQuery();
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// The parameter of "query" is of type ZLMessageSearchHomeService.SearchQuery,
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// but needs to be of type ZLMessageSearchQueryHomeService.SearchQuery
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
var results = messageSearchService.search(messageSearchSession, "someDomain.domain.com", query);
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
}
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
private static SearchQuery GetMessageSearchQuery()
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
{
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// Create the service and session for getting the paramter
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
var messageQueryService = new MessageSearchQueryHomeService();
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
var messageQuerySession = new MessageQuerySession();
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// Create the SearchQuery object and parameters
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
SearchQuery mainQuery = messageQueryService.create(messageQuerySession, "This Query", 1);
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
SearchCondition dateRange = messageQueryService.makeDateRangeCondition(messageQuerySession, mainQuery,
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

"CreationDate", new DateTime(2011, 1, 1),
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

new DateTime(2011, 1, 30));
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
// Put the query and parameters together and return the resulting SearchQuery
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
SearchQuery resultsQuery = messageQueryService.close(messageQuerySession, mainQuery, dateRange);
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px

<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
return resultsQuery;
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
}
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
}
<p style="widows:2; text-transform:none; background-color:#ffffff; text-indent:0px; font:12px Verdana,Arial,Helvetica,sans-serif; white-space:normal; orphans:2; letter-spacing:normal; color:#000000; word-spacing:0px
}
<br/>

View the full article
 
Back
Top