c# - WCF Service in windows phone 7 -
i have problem connecting wcf service , windows phone. have service no source code (only publish on web) , need use in windows phone 7 app.
i add service reference in project, vs generated me file servicereferences.clientconfig:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.servicemodel> <bindings> <basichttpbinding> <binding name="httpbinding_iwcfmobilservices"> <security mode="none" /> </binding> </basichttpbinding> </bindings> <client> <endpoint address="http://www.www.com/wcfmobilservices.svc" binding="basichttpbinding" bindingconfiguration="httpbinding_iwcfmobilservices" contract="mobileservice.iwcfmobilservices" name="httpbinding_iwcfmobilservices"></endpoint> </client> </system.servicemodel> </configuration>
when call service method:
public static void login() { var proxy = new mobileservice.wcfmobilservicesclient(); proxy.loginasync("loginname", "paswword"); proxy.logincompleted += (s, a) => { //some code }; }
application in logincompleted throw me exception on a.result :
system.servicemodel.protocolexception: content type text/xml; charset=utf-8 not supported service http://www.www.com/wcfmobilservices.svc. client , service bindings may mismatched. ---> system.net.webexception: remote server returned error: notfound. ---> system.net.webexception: remote server returned error: notfound. @ system.net.browser.clienthttpwebrequest.internalendgetresponse(iasyncresult asyncresult) @ system.net.browser.clienthttpwebrequest.<>c_displayclasse.b_d(object sendstate) @ system.net.browser.asynchelper.<>c_displayclass1.b_0(object sendstate) --- end of inner exception stack trace --- @ system.net.browser.asynchelper.beginonui(sendorpostcallback beginmethod, object state) @ system.net.browser.clienthttpwebrequest.endgetresponse(iasyncresult asyncresult) @ system.servicemodel.channels.httpchannelfactory.httprequestchannel.httpchannelasyncrequest.completegetresponse(iasyncresult result) --- end of inner exception stack trace --- @ system.componentmodel.asynccompletedeventargs.raiseexceptionifnecessary() @ w7app.mobileservice.logincompletedeventargs.get_result()} system.servicemodel.communicationexception {system.servicemodel.protocolexception}
any idea what's wrong?
i tried change binding in config file wshttpbinding, vs shows me warning:
the element 'bindings' has invalid child element 'wshttpbinding'. list of possible elements expected: 'basichttpbinding, custombinding'.
thanks
following on our conversation. silverlight / windows phone 7 only supports basichttpbinding
, custombinding
. creating console application able connect using wshttpbinding
. so, options are:
- ask
basichttpbinding
added end-point. - create wcf service sits between windows phone , other wcf service. way can connect
basichttpbinding
, intermediate wcf can usewshttpbinding
connect other service.
obviously, option 2 slower , add complication , hassle on updates unless option 1 possible don't think have many other choices.
Comments
Post a Comment