Open RIA Services User Support Troble calling Login method of the AuthenticationService  Viewed 18534 time(s), 5 post(s)., 6/7/2015 7:18:32 PM - by ankuranand

ankuranand
ankuranand 6/8/2015 2:12:32 PM

I have OpenRIA hosted within an asp.net website. I have a WPF client that connects to the Authentiction and DomainService. I am having trouble calling the Login method. It basically does not like that the message parameters are not "Wrapped". See the error message below

An unhandled exception of type 'System.InvalidOperationException' occurred in OpenRiaServices.DomainServices.Client.dll

Additional information: Operation 'Login' of contract 'IPatientAuthenticationDomainServiceContract' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra body parameters or set the BodyStyle property on the WebGetAttribute/WebInvokeAttribute to Wrapped.

On the client side, The WebHttpBehavior in domainClient.ChannelFactory.Endpoint.EndpointBehaviors has DefaultBodyStyle = Wrapped

The asp.net project that's hosting the OpenRIA services has web behavior set to Wrapped.
<system.serviceModel>
<behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp defaultBodyStyle="Wrapped"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

What could I be missing? Has anyone encountered this issue?

Thanks,

Ankur

This content has not been rated yet. 
35 Reputation 3 Total posts
1
ankuranand
ankuranand 6/8/2015 11:30:20 PM

Issue resolved. Just wanted to share the fix. I am using SharedCookieContainer that Kyle McClellan wrote for sharing cookie between Auth service and Domain service when not using an in-browser client. See http://blogs.msdn.com/b/kylemc/archive/2010/05/14/ria-services-authentication-out-of-browser.aspx

The SharedCookieBehavior in this code is an extension of WebHttpBehavior. This class needs to have the DefaultBodyStyle set to Wrapped when its newed up. Simpe fix but took me a while to figure out.

Thanks,

Ankur

This content has not been rated yet. 
35 Reputation 3 Total posts
2
tomas
tomas 8/26/2015 1:14:55 PM

Hi Ankur,

I am converting SL app to WPF and I am now having trouble even with instantiating of AuthenticationContext on application startup.
I am getting this:
An exception of type 'System.ArgumentException' occurred in OpenRiaServices.DomainServices.Client.Web.dll but was not handled in user code
Additional information: The specified service URI is not correctly formatted.

Some detail about this problem are even here:
http://www.openriaservices.net/MonoX/Pages/SocialNetworking/Discussion/dtopic/wjP0P8zwwkWVzaSSAR1IbA/Test-WPF-Application/

Obviously, I have now problem how to set up projects in  my solution in order to WPF part comunicate with WCF...

Could you please elaborate more how did you make it work?

Thank you,
Tomas

This content has not been rated yet. 
16 Reputation 3 Total posts
3
Daniel-Svensson
Daniel-Svensson 9/1/2015 5:10:11 PM

@Tomas.

Currently you must always specify absolute adresses for WPF applications, here is an example of how to do so for the authentication service:

<div>

WebContext webContext = new WebContext();
webContext.Authentication = new FormsAuthentication()
    {
        DomainContext = new AuthenticationDomainService1(
             new WebDomainClient<AuthenticationDomainService1.IAuthenticationDomainService1Contract>(
                 @"http://localhost:51359/ClientBin/SilverlightApplication1-Web-AuthenticationDomainService1.svc/")
            )
    };

</div>

This content has not been rated yet. 
338 Reputation 44 Total posts
4
Daniel-Svensson
Daniel-Svensson 2/7/2016 2:28:28 PM

I first beta release of 4.5.0 has been pushed to nuget and a link to a my portable replacement to the WCF client can be found in the description
https://openriaservices.codeplex.com/releases/view/619745.

The release introduces some small changes in how DomainClients gets created (via WcfDomainClientFactorywhich might help with implementing SharedCookieBehavior centrally).
You should be able to specify your base Uri at Application startup and then just use relative Uri's (using default constructor).

This content has not been rated yet. 
338 Reputation 44 Total posts
5