Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How to call WCF Service that requires Headers from Silverlight -


wcf 3.5 sp1 services / called silverlight 4

in situation vendor has created wcf api, both svc services, custom proxy client.

both aspects of api sit on top of core four-layer abstraction.

first there 2 abstract messagecontract classes: wcfrequest , wcfresponse.

the abstract wcfrequest type contains properties decorated messageheader attribute, , contain things such custom authentication identifier , timezone.

then there second layer of onion each method divided 2 classes: getsomethingrequest , getsomethingresponse, both of inherit wcfrequest , wcfreponse, respectively.

next comes implementation layer, wcfrequest , wcfresponse based types bubble , invoked custom wcfclient type, controls channelfactory construction, establishes binding, , importantly, sets identifier header in wcfrequest type based on set value in memory (like session key).

lastly comes view ouside world, request poco types via id values.

now, api written in such way if use vendor supplied proxy, things work expected - authentication occurs , identifier set, , can call method call without problem.

if you've made far, sticking me.

now, problem occurs when want write silverlight client, using either "add service reference" or slsvcutil, none of proxy client types generated have these header properties wcfrequest header set, , not defined in message prototype parameters pass in.

to set these headers, i've looked @ wcfextras project on codeplex , tried use clientsoapheaderhelper routines, doesn't work silverlight (no extension capability).

i've tried operationcontext - see if set header there, that's null - @ least if inspect in client proxy method.

are person knows how manually (hack) these headers place?

thanks assistance...but totally understand if gets no hits.

i ran in problem of custom headers while ago... needed write headers little differently internal classes wanted (it apache service).

here way got around (three classes).

inside operation context create new instance of headerserializer class. class based on headerserializerbase (my class too) based on xmlobjectserializer. headerserializerbase uses writeraw write string in header (in case stored in app, build dynamically no problems).

hth :)

using (operationcontextscope ocs = new operationcontextscope(client.innerchannel))             {                  var ser = new headerserializer();                 operationcontext.current.outgoingmessageheaders.add(messageheader.createheader("securityheader",                                                                                                "http://somesite.com/schema",                                                                                                authheader, ser));                                  var req = new getpredefinedsearchresultsrequest()                               {                                   someproperty = somevalue                               };                  client.getpredefinedsearchresultsasync(req);             }                 public class headerserializer : headerserializerbase             {                 public epgheaderserializer()                 {                     base.autheheaderstring = xamlingcore.infrastructure.resource.resourceloader.loadstringresource("assembly.data", "rawheaderdata.txt");                 }             }                 public class headerserializerbase : xmlobjectserializer             {                 protected string autheheaderstring;                  public override void writestartobject(xmldictionarywriter writer, object graph)                 {                     throw new notimplementedexception();                 }                  public override void writeobjectcontent(xmldictionarywriter writer, object graph)                 {                     writer.writeraw(autheheaderstring.tochararray(), 0, autheheaderstring.length);                 }                  public override void writeendobject(xmldictionarywriter writer)                 {                     throw new notimplementedexception();                 }                  public override object readobject(xmldictionaryreader reader, bool verifyobjectname)                 {                     throw new notimplementedexception();                 }                  public override bool isstartobject(xmldictionaryreader reader)                 {                     throw new notimplementedexception();                 }             } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -