In my case i'm using wsdl.exe in windows to generate the proxy and works like a charm, just copy the generated .cs and everything works perfect.
2014-03-27 7:29 GMT+01:00 spcware <[email protected]>: > I was able to solve it. In order to get a valid SOAP client using > Xamarin/Monotouch running on iOS, you must use the Silverlight soap proxy > generator: slsvcutil.exe. this is because iOS does not allow dynamic code > execution and the standard soap proxy generator: svcutil.exe creates a > client that depends on dynamic code execution. The Silverlight generator > produces a simpler client without dynamic code execution. However, it is > too simple in that it does NOT support soap headers. > > My solution to this problem is to still use the Silverlight soap proxy > generator, but then implement 2 classes to manually add in the soap headers > before the soap requests go out during runtime. Here are the two classes I > implemented. You will see that the second class contains the > BeforeSendRequest method which I override to manually add in my soap > headers. Of course, your soap headers will be different than mine. Then > to > use these two classes, you add an endpoint behavior to your client when you > construct it: client.Endpoint.Behaviors.Add (new > EditorialSoapHeaderBehavior (appName,sessionId)); > > private class EditorialSoapHeaderBehavior : > IEndpointBehavior > { > private string _appName = null; > private string _sessionId = null; > > public EditorialSoapHeaderBehavior(string > appName,string sessionId) > { > _appName = appName; > _sessionId = sessionId; > } > > public void AddBindingParameters (ServiceEndpoint > endpoint, > BindingParameterCollection parameters) > { > } > public void ApplyDispatchBehavior (ServiceEndpoint > endpoint, > EndpointDispatcher dispatcher) > { > } > public void ApplyClientBehavior (ServiceEndpoint > endpoint, ClientRuntime > runtime) > { > runtime.MessageInspectors.Add (new > EditorialSoapHeaderInspector > (_appName,_sessionId)); > } > public void Validate (ServiceEndpoint endpoint) > { > } > } > > private class EditorialSoapHeaderInspector : > IClientMessageInspector > { > private string _appName = null; > private string _sessionId = null; > > public EditorialSoapHeaderInspector(string > appName,string sessionId) > { > _appName = appName; > _sessionId = sessionId; > } > > public void AfterReceiveReply (ref Message > message, object > correlationState) > { > } > public object BeforeSendRequest (ref Message > message, IClientChannel > channel) > { > MessageHeader mh = > MessageHeader.CreateHeader ("ApplicationName", > "IHS.Core.Security.WCF", _appName); > message.Headers.Add (mh); > mh = MessageHeader.CreateHeader > ("SessionId", "IHS.Core.Security.WCF", > _sessionId); > message.Headers.Add (mh); > return(null); > } > } > > > > > -- > View this message in context: > http://monotouch.2284126.n4.nabble.com/SOAP-WebService-with-SOAP-Header-Attributes-failing-tp4261555p4658561.html > Sent from the MonoTouch mailing list archive at Nabble.com. > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
