Select to view content in your preferred language

Sending Map instance to WCF service

956
2
10-29-2012 01:17 PM
MosesAsuquo
Deactivated User
I have a pdf printing project that is not built for silverlight assemblies. I decided to wrap the project functionality in a WCF service so that i can use is in my silverlight application. The only thing is that i need the map instance to be sent through WCF to the backend project so that i can print the map to PDF. Is there is a way i can send the MapApplication.Current.Map instance through WCF to the backend service. I have tried and i get serialization errors. I know the map instance will be different from normal serialization some how but i don't know how to go about serializing it for the WCF service.


This is the error i get from the service when i call it asynchronously from the silverlight map application:

Error: Cannot obtain Metadata from http://localhost:63761/PrintMapService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?Link...55.WS-Metadata Exchange Error URI: http://localhost:63761/PrintMapService.svc Metadata contains a reference that cannot be resolved: 'http://localhost:63761/PrintMapService.svc'. The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.HTTP GET Error URI: http://localhost:63761/PrintMapService.svc There was an error downloading 'http://localhost:63761/PrintMapService.svc'. The request failed with the error message:--<html> <head> <title>Type 'System.Windows.UIElement' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. ÿIf the type is a collection, consider marking it with the CollectionDataContractAttribute. ÿSee the Microsoft .NET Framework documentation for other supported types.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style> </head> <body bgcolor="white"> <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> <h2> <i>Type 'System.Windows.UIElement' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. ÿIf the type is a collection, consider marking it with the CollectionDataContractAttribute. ÿSee the Microsoft .NET Framework documentation for other supported types.</i> </h2></span> <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br><br> <b> Exception Details: </b>.........

Here is the WCF service interface


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using ESRI.ArcGIS.Client;

namespace PrintMapWcfService
{
    [ServiceContract]
    public interface PrintService
    {

        [OperationContract]
         void CreatePDF(Map _map);
    }
}




Any useful suggestion will be greatly appreciated.

thanks in advance.
0 Kudos
2 Replies
MosesAsuquo
Deactivated User
I have a pdf printing project that is not built for silverlight assemblies. I decided to wrap the project functionality in a WCF service so that i can use is in my silverlight application. The only thing is that i need the map instance to be sent through WCF to the backend project so that i can print the map to PDF. Is there is a way i can send the MapApplication.Current.Map instance through WCF to the backend service. I have tried and i get serialization errors. I know the map instance will be different from normal serialization some how but i don't know how to go about serializing it for the WCF service.


This is the error i get from the service when i call it asynchronously from the silverlight map application:

Error: Cannot obtain Metadata from http://localhost:63761/PrintMapService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?Link...55.WS-Metadata Exchange Error URI: http://localhost:63761/PrintMapService.svc Metadata contains a reference that cannot be resolved: 'http://localhost:63761/PrintMapService.svc'. The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.HTTP GET Error URI: http://localhost:63761/PrintMapService.svc There was an error downloading 'http://localhost:63761/PrintMapService.svc'. The request failed with the error message:--<html> <head> <title>Type 'System.Windows.UIElement' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. ÿIf the type is a collection, consider marking it with the CollectionDataContractAttribute. ÿSee the Microsoft .NET Framework documentation for other supported types.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style> </head> <body bgcolor="white"> <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> <h2> <i>Type 'System.Windows.UIElement' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. ÿIf the type is a collection, consider marking it with the CollectionDataContractAttribute. ÿSee the Microsoft .NET Framework documentation for other supported types.</i> </h2></span> <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif "> <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br><br> <b> Exception Details: </b>.........

Here is the WCF service interface


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using ESRI.ArcGIS.Client;

namespace PrintMapWcfService
{
    [ServiceContract]
    public interface PrintService
    {

        [OperationContract]
         void CreatePDF(Map _map);
    }
}




Any useful suggestion will be greatly appreciated.

thanks in advance.


This problem has been resolved. Thanks
0 Kudos
G__Venkata_VijayaKumar
Occasional Contributor
This problem has been resolved. Thanks


Could you please share the solution here or with me at gantibabu at gmail dot com.

Thanks
0 Kudos