Reputation: 6752
I have a WCF service which I added to my Monotouch project using the instructions here. The Service works, but when it throws a FaultException, the client bombs with an error:
Expected element 'ExceptionDetail' in namespace 'http://schemas.datacontract.org/2004/07/System.ServiceModel', but found Element node 'MyTypeException' in namespace ...
I'm setting up the client programmatically
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "BasicHttpBinding_IService";
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.Security.Mode = BasicHttpSecurityMode.None;
EndpointAddress address = new EndpointAddress("http://myaddress.com/MyService.svc");
LoyaltyClient client = new LoyaltyClient(binding, address);
Any ideas?
Upvotes: 1
Views: 546
Reputation: 19335
This is a bug in MonoTouch (which has been filed several times).
The bug has been fixed, and the fix will most likely be included in the next version after 5.2 (though you might be able to get a hotfix if you contact support).
Update: November 13, 2014
For users hitting this issue in more recent versions (after Xamarin.iOS 7 for example), note that the Mono WCF implementation requires the [FaultContract]
when deserializing FaultException<T>
instances that use custom types T
for the exception details.
For example, you'll need to add the [FaultContract]
attribute to the method that throws the FaultException
in the server-side service contract:
[OperationContract]
[FaultContract(typeof(ContentFaultType))]
void MyMethodThatThrowsAFaultException();
After deploying this server-side change change you'll need to re-generate the client-side Silverlight proxy using SlSvcUtil.
Upvotes: 4
Reputation: 171188
Looks like you did not declare the fault class using the FaultContractAttribute. When you don't do this the schema of the fault class does not go into the WSDL so the client does not know of it.
Upvotes: 0