我正在尝试通过Silverlight 4 OOB应用程序使用WCF服务。服务本身只返回由基元组成的类(String,DateTime,int ...)。我将它作为IIS中的Web应用程序托管。
类和它的属性都用[DataContract]和[DataMember]标记,我添加了正确的端点等。所以配置是好的,至少看起来如此。
奇怪的是,我必须多次尝试在服务工作之前调用服务。当通过单元测试从同一个项目调用它时,它总是从第一次开始工作。
当我查看Fiddler中的响应时,我看到一个干净的反序列化XML,没有错误,所以这个工作!部分回复:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Response xmlns="http://tempuri.org/">
<Number>82072826584</Number>
<Date>28/07/1982</Date>
<Sex>1</Sex>
</Response>
</s:Body>
</s:Envelope>
但是在我的SL客户端中,Result包含一个带有InnerException(片段)的TargetInvocationException:
{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound.
---> System.Net.WebException: The remote server returned an error: NotFound.
---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
错误本身包含以下内容(摘录):
{System.Net.WebException: The remote server returned an error: NotFound.
---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
我在WCF配置中启用了异常,但它在发回的实际错误中没有区别。起初我想也许有些部分由于非SL类而无法序列化,但是当我继续尝试它最终起作用时......对我来说没有任何意义。
有什么想法吗?