Casting RawPage from EPiServer Webservice to Core.RawPage or Core.PageData ?

Vote:
 

Hi,

Using Episerver 4,61

Iam getting a page through episerver webservice.

WebService.DataFactoryService factory = new Devlopment.Web.UI.WebService.DataFactoryService();

Devlopment.Web.UI.WebService.PageReference pr = new Devlopment.Web.UI.WebService.PageReference();
pr.ID = 3727;

Devlopment.Web.UI.WebService.RawPage rawPage = factory.GetPage(pr);

The problem is, i want to cast the WebService.RawPage to a normal Core.RawPage or Core.PageData object i get invalid cast.
EPiServer.Core.RawPage _newRawPage = ((EPiServer.Core.RawPage)rawPage);

Whats the best way to do this ? any idea ?

Thanks
Jeppe

 

#19655
Apr 23, 2008 11:46
Vote:
 

EpiServer's DataFactoryService resides under the namespace EPiServer.WebServices, are you sure You are referencing the correct webservice here? You're code implies something calyed 'Devlopment.Web.UI.WebService.DataFactoryService', is this correct and intended?

Also, the standard DataFactoryService methods *do* already deal with EPiServer.Core.RawPage's, so no cast would be needed.

Also, if you want to get a PageData object, there is a suitable constructor for the PageData class that takes a RawPage as argument.

Regards,
Johan

#19670
Apr 24, 2008 9:56
Vote:
 

Hi Johan,

Thanks for the replay. I think the namespaces are right, WebServices is the webreference  (to the webservice) in the UI project.

Yes i tried to add the rawpage in the PageData constructor, but get this.

EPiServer.Core.PageData test = new EPiServer.Core.PageData(rawPage);

Error 118 Argument '1': cannot convert from Devlopment.Web.UI.WebService.RawPage' to 'EPiServer.Core.PageReference'

Error 117 The best overloaded method match for 'EPiServer.Core.PageData.PageData(EPiServer.Core.PageReference)' has some invalid arguments

The PageData constructor needs a EPiServer.Core.RawPage as argument, and my RawPage from the webservice in not of that type.

Guess iam missing something here :P

Any idea ?

Thanks
Jesper




#19673
Apr 24, 2008 11:22
Vote:
 

Oh I see, You are referencing the DataFactoryService from *within* the actual project that also has references to EPiServer.dll ...

Well, in that case I'd recommend you to remove the webreference to DataFatoryService.asmx altogether and instead access it from the namespace EPiServer.WebServices.

Somehting like this:

EPiServer.WebServices.DataFactoryService dfs = new EPiServer.WebServices.DataFactoryService();

dfs.Url = "serverurl";
EPiServer.Core.RawPage rawPage = dfs.GetPage( new EPiServer.Core.PageReference(31112));
EPiServer.Core.PageData pageData = new EPiServer.Core.PageData(rawPage);

/johan

 

#19694
Apr 28, 2008 11:15
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.