开发者

Silverlight4 calling ASMX web service

I have a Visual Studio solution with a Silverlight project, and a web project which hosts the Silverlight app. The web project also contains an ASMX web service which is called by the Silverlight ap.

As described below, certain calls to the web service work fine, and yet others cause a CommunicationException to be thrown, wrapping a WebException - both with the message "The server returned the following error: 'not found'".

Firstly, here's my original method, which failed as described above (entity names changed for simplicity):

[WebMethod]
public Customer GetCustomer(int id)
{
    CustomerDataContext dc = new CustomerDataContext();
    return dc.Customers.SingleOrDefault(x => x.Id == id);
}

Secondly, to debug the problem I took Linq to SQL and the database out of the picture, and the below code worke开发者_开发问答d fine:

    [WebMethod]
public Customer GetCustomer(int id)
{
    Customer c = new Customer() { ID=1, Name="Bob", History = new EntitySet<CustomerHistory>() };
    return c;
}

Third, thinking about this, one difference between the two methods is that the first one would include values in the customer history. I extended the second method to include this, and it started failing again:

    [WebMethod]
public Customer GetCustomer(int id)
{
    Customer c = new Customer() { ID=1, Name="Bob", History = new EntitySet<CustomerHistory>() };
    c.History.Add(new CustomerHistory() { Id=1, CustomerId=1, Text="bla" });
    return c;
}

I'm stuck with regards to how to progress - my current thinking is that this could be a deserialization issue on the Silverlight side, when the object graph is deeper. This rationally doesn't make sense, but I can't think of anything else. I've confirmed that the transfer size and buffer size are big enough (2GB by default).

Any pointers would be appreciated.


Ahhhh the famous "Not Found" error, try to get details from that error using the tag in your web.config. That will create a log file providing details of the error.

The following link explains exaclty how to do it :

http://blogs.runatserver.com/lppinson/post/2010/04/15/Debugging-WCF-Web-Services.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜