.net - Why does Silverlight not call AfterReceiveReply for my custom ServiceModel.ClientBase<TChannel> channel's behavior? -


i have service reference third-party api. use custom channelfactory class build channels ([wcf] of type system.servicemodel.clientbase) api.

i have custom behavior class (defined below) attach channel endpoint in order handle exceptions api. in normal .net code, works fine. in silverlight, however, afterreceivereply method called if there no error.

in case, calling method encounters error when try reference result of eventargs: 'eventargs.result' threw exception of type 'system.reflection.targetinvocationexception'.

the inner exception has: innerexception = {system.servicemodel.communicationexception: remote server returned error: notfound.

and see above error regardless of real error. in fiddler, can see real error coming back. there channel processing hides it. below example of soap response has real error. (some values removed.)

<?xml version="1.0" encoding="utf-8"?> <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:xsd="http://www.w3.org/2001/xmlschema"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">   <soapenv:body>     <soapenv:fault>       <faultcode><!-- removed real code --></faultcode>       <faultstring><!-- removed real fault --></faultstring>       <detail>         <!-- removed details -->       </detail>     </soapenv:fault>   </soapenv:body> </soapenv:envelope> 

i'm sure haven't provided enough information yet, don't know relevant. ask more info in comments.

how can go debugging this? same code works in .net, silverlight doesn't handle well.

some relevant code below.

behavior:

public class exceptionmapperbehavior : iclientmessageinspector, iendpointbehavior {     public void afterreceivereply(ref message reply, object correlationstate)     {         //this called if there no fault--not helpful!         if (reply == null || !reply.isfault)             return;          //todo: make exception pretty     }      public object beforesendrequest(ref message request, iclientchannel channel)     {         //this called         return null;     } } 

channel creation:

//... var constructor = typeof(t).getconstructor(new type[] { typeof(binding), typeof(endpointaddress) }); var ret = (t)constructor.invoke(new object[] { binding, endpointaddress }); ret.endpoint.behaviors.add(new credentialinserterendpointbehavior(_authtoken)); ret.endpoint.behaviors.add(new exceptionmapperbehavior()); return ret; 

don't know if helps/uses something.

by default silverlight performs http-requests (include soap/rest) through browser. these calls http/https requests handled silverlight-client network stack.

bool httpresult = webrequest.registerprefix("http://", webrequestcreator.clienthttp); bool httpsresult = webrequest.registerprefix("https://", webrequestcreator.clienthttp); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -