It looks like the SOAP message sent from the iPhone application is not in the format expected by the WCF service. In this case, you probably have to control more the serialization of NSMutableArray of CustomObjectClass es when passing the array to the method.
To check if this is a problem, you can implement and configure a WCF message inspector that will write a SOAP request message to a file, and then look at the file to see if this looks like the following SOAP message:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:Header> <a:Action s:mustUnderstand="1">http://tempuri.org/IService/SendData</a:Action> <a:MessageID>urn:uuid:8a582916-1b9a-47f8-8fb1-c9ff18420391</a:MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand="1">net.tcp://localhost:13031/Service</a:To> </s:Header> <s:Body> <SendData xmlns="http://tempuri.org/"> <ssf xmlns:b="http://schemas.datacontract.org/2004/07/Common" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <b:CustomObjectClass> </b:CustomObjectClass> </ssf> </SendData> </s:Body> </s:Envelope>
Implement WCF Message Inspector:
- Implement the WCF Message Inspector (
IDispatchMessageInspector ). - Implement endpoint behavior (
IEndpointBehavior ). - Implement a custom behavior extension element (
BehaviorExtensionElement ).
WCF Message Inspector :
public class FileOutputMessageInspector : IDispatchMessageInspector { public object AfterReceiveRequest( ref Message request, IClientChannel channel, InstanceContext instanceContext ) { string path = Path.Combine( AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Guid.NewGuid().ToString() + ".xml" ); File.WriteAllText( path, request.ToString() ); return null; } public void BeforeSendReply( ref Message reply, object correlationState ) { } }
endpoint behavior :
public class FileOutputBehavior : IEndpointBehavior { public void AddBindingParameters( ServiceEndpoint endpoint, BindingParameterCollection bindingParameters ) { } public void ApplyClientBehavior( ServiceEndpoint endpoint, ClientRuntime clientRuntime ) { throw new ApplicationException( "Behavior is not supported on client side." ); } public void ApplyDispatchBehavior( ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher ) { FileOutputMessageInspector inspector = new FileOutputMessageInspector(); endpointDispatcher.DispatchRuntime.MessageInspectors.Add( inspector ); } public void Validate( ServiceEndpoint endpoint ) { } }
Extension element behavior:
public class FileOutputElement : BehaviorExtensionElement { public override Type BehaviorType { get { return typeof( FileOutputBehavior ); } } protected override object CreateBehavior() { return new FileOutputBehavior(); } }
Configure WCF Message Manager:
- Declaring a new behavior extension (make sure the
type attribute uses the correct fully qualified type name). - Use declared behavior extension in endpoint behavior.
- Link to endpoint behavior.
Use the following configuration as a reference:
<system.serviceModel> <services> <service name="Server.Service"> <endpoint address="" binding="netTcpBinding" bindingConfiguration="TCP" contract="Common.IService" behaviorConfiguration="RequestMessageToFile"/> <host> <baseAddresses> <add baseAddress="net.tcp://localhost:13031/Service"/> </baseAddresses> </host> </service> </services> <bindings> <netTcpBinding> <binding name="TCP"> <security mode="None"/> </binding> </netTcpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="RequestMessageToFile"> <requestFileOutput /> </behavior> </endpointBehaviors> </behaviors> <extensions> <behaviorExtensions> <add name="requestFileOutput" type="Common.FileOutputElement, Common"/> </behaviorExtensions> </extensions> </system.serviceModel>