Can a WCF Service return a Datatable ??

The snippet shown below is not working ??? Why is it 
namespace MLA_CRM_Service
    [DataContract]
    public class MLAContact : DataTable  //(Cant i do this ?)
        [DataMember]
        private string MLAMemberType;
        [DataMember]
        private string MLAMemberNo ;
        [DataMember]
        private string fullName;
        [DataMember]
        private string companyName;
        [DataMember]
        private string addressLine1;
        [DataMember]
        private string addressLine2;
        [DataMember]
        private string suburb;
        [DataMember]
        private string state;
        [DataMember]
        private string postCode;
        [DataMember]
        private string country;
        [DataMember]
        private string emailAddress;
        [DataMember]
        public string _MLAMemberType
            get;
            set;
        [DataMember]
        public string _MLAMemberNo
            get;
            set;
        [DataMember]
        public string FullName
            get;
            set;
        [DataMember]
 .// All Getters and setter are implemented 
        [DataMember]
        public string EmailAddress
            get;
            set;
 public MLAContact()
            this.Columns.Add(new DataColumn("MLAMemberType", typeof(string)));
            this.Columns.Add(new DataColumn("MLAMemberNo", typeof(string)));
            this.Columns.Add(new DataColumn("FullName", typeof(string)));
            this.Columns.Add(new DataColumn("CompanyName", typeof(string)));
            this.Columns.Add(new DataColumn("AddressLine1", typeof(string)));
            this.Columns.Add(new DataColumn("AddressLine2", typeof(string)));
            this.Columns.Add(new DataColumn("Suburb", typeof(string)));
            this.Columns.Add(new DataColumn("State", typeof(string)));
            this.Columns.Add(new DataColumn("PostCode", typeof(string)));
            this.Columns.Add(new DataColumn("Country", typeof(string)));
            this.Columns.Add(new DataColumn("EmailAddress", typeof(string)));
public DataRow AddRows(usp_SecondaryContactCollectionResult content) {
DataRow dr = this.NewRow(); dr["FullName"] = content.FullName.ToString();
dr["EmailAddress"] = content.emailaddress.ToString(); return dr;
public DataRow AddRows(usp_GetUserDetailsResult content) {
DataRow dr = this.NewRow(); dr["MLAMemberType"] = content.MLAMemberType;
dr["MLAMemberNo"] = content.MemberNumber;
dr["FullName"] = content.FullName;
dr["CompanyName"] = content.CompanyName;
dr["AddressLine1"] = content.AddressLine1;
dr["AddressLine2"] = content.AddressLine2;
dr["Suburb"] = content.Suburb;
dr["State"] = content.State;
dr["PostCode"] = content.PostCode;
dr["Country"] = content.Country;
dr["EmailAddress"] = content.emailaddress;
return dr;
Now the Service method implementation
public DataTable SecondaryContactCollection(int contactID, string token)
            try
                using (ContactDataContext = new MLAWebUsers_ContactsDataContext())
                    MLAContact mlaContact = new MLAContact();
                    DataTable dt = new MLAContact();
                   var container = ContactDataContext.usp_SecondaryContactCollection(contactID, token);
                    foreach (usp_SecondaryContactCollectionResult item in container)
                        dt.ImportRow( mlaContact.AddRows(item));
                    return dt;
            catch (Exception ex)
                throw ex;
Now the above code compiles perfectly .... But when i try to consume it in the client side ...
Exception is thrown 
Client side Code
protected void Page_Load(object sender, EventArgs e)
                DataTable dt = new DataTable();
                int i = 0;
                int a = 145417;
                string x = "A1F3CKeog&";
                MLA_CRM_ServicesClient clientEndPoint = new MLA_CRM_ServicesClient("BasicHttpBinding_IMLA_CRM_Services");
                dt = clientEndPoint.SecondaryContactCollection(a, x);
                i = dt.Rows.Count;
                Label1.Text = i.ToString();
The above line that is Bold in the client code, thats the place where the exception is thrown .... Have gone through the stack trace still not able to fix it !!!!
Regards,
Chandra.

you have two options
Option 1
Simply give your Table a name. If you don’t,it will block the client and time out which throws an unexpected exception.
DataTable dt = new MLAContact("SomeTableName");
Option 2
Create a dataset and Add your datatable and return datatable from dataset i.e
DataTable dt = new MLAContact();
DataSet ds =
new
DataSet
ds.Tables.Add(dt);
return
ds.Tables[0];
Reason:
The root reason is the DataTable inside a dataset inherits a schema namespace from the dataSet, but an independent datatable has an empty namespace (unless we change it).  Data cannot be changed between two dataTables with different namespace.
If
this helps do not forget to mark it as Answer
  I would recomend you to go ahead with Option 1. And share your views.
Lingaraj Mishra

Similar Messages

  • Can a remote service return a remote object?

    Hi all,
    please consider a business logic for a typical forum service :
    public interface ForumManager extends Remote
    Forum createNewForum(String Name);
    Forum getForum(String Name);
    public interface Forum extends Remote
    void postNewArticle(String Title, String Content);
    Article [] getArticles();
    public class Article implements Serializable
    There are two interfaces of remote objects: ForumManager and Forum, both of two interfaces are extended from interface Remote. I created two classes implementing these interfaces respectively, and created two stub classes from the implementation with rmic.
    As the logic, a ForumManager creates and manages forums on the server. A client can retrieve a remote stub of a forum instance from the manager stub, and post articles to the forum stub. The forum stub then sends the new articles to the real ForumImpl on the server, and the real implementation of Forum on the server then save the articles into disks or DBs. So, you can see, the most important thing is that clients have to be able to get the stub of a forum.
    Codes in createForum() of the implementation class of ForumManager is like this:
    ForumImpl TheNewForum = new ForumImpl(this.getRef());
    // ^ Because ForumImpl is a remote object, without a ref, it can not be marshaled.
    ForumTable.put(Name, TheNewForum);
    return TheNewForum;
    The problem is, the Forum instance my client retrieved from FourmManagerImpl_Stub (gotten from Naming.lookup()) is a ForumImpl, but not a Forum_Stub. So that articles posted to the forum will not be sent to the server, and different clients can not share articles with each other. I found a bunch of documents about RMI, but they did not illustrated how to retrieve a stub of a remote object from another remote object (like a manager). If you know how to cope this problem, please tell me.
    Edited by: DBPZ on Apr 2, 2008 3:33 AM

    why does this base class exist?It's really only there to support stubs. The only thing it gives you over Object is the remote equality semantics, and only stubs need that. (It also provides the RemoteReference but only RMI needs that, internally, you don't.)
    When should we use RemoteObject instead of UnicastRemoteObject?Never, but if you do, or you use Object (or indeed anything other than UnicastRemoteObject and Activatable), you have to export it yourself as indicated above.

  • Can MDM Web Services return qualifier values?

    We are running MDM 5.5 SP06 Patch04 (we will be doing a technical upgrade to MDM 7 later this year).
    I am investigating the MDM web services and came upon a potential problem. In the test harness, I searched for a record, specifying ALL for the result definition and everything seemed to come back except qualifiers; lookup values came back, taxonomy values came back, qualified lookup display values came back, qualified link ids came back, but no qualifier values.
    I searched again on the qualified link record ids in the qualified lookup table and I got the non-qualifiers, which is the expected behavior. The qualifiers have to come back with the main table record, though.
    Are qualifiers not fully supported in the MDM 5.5 web services, or am I not searching properly?
    Thanks for any help you can provide.
    Doug

    Hi Doug
    For me all  are working good.
    Can you look at pages 24-26 from "Portal content development guide"
    https://websmp201.sap-ag.de/~sapidb/011000358700001119612007E
    Regards
    Kanstantsin

  • Is there a way for converting WCF service into Azure Cloud Service without dealing with project files.

    Here is my situation.
    We provide Platform and SDK to other people where they can build WCF services and deploy that on site. We have a  many ISVs who has built wcf services, packaged them and ship them.
    Packaging consist of couple of manifest file and .dll file that make up wcf service. Now we want to go on cloud with our platform.
    Long story short - I have all the dlls for my wcf service but no project file.
    Is there a way to generate cloud service package from this dll files?

    Hi,
    You can't simply package your dlls and deploy it as a azure cloud service deployment package - you will need to have your project as well as service definition file which will define your role and instances.
    You can read more about packaging an Application by Using the CSPack Command-Line Tool here -http://msdn.microsoft.com/en-us/library/azure/gg433133.aspx
    another way to go to cloud platform is by making use of azure web sites, however you will still need your service files do deploy.
    If you have the dlls and the service files with you - then you can simply use the web site publish wizard and deploy to azure web site.
    Read more about it here - http://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/
    Bhushan | Blog |
    LinkedIn | Twitter

  • How we can limit the number of concurrent calls to a WCF service without use the Singleton pattern or without do the change in BizTalk Configuration file?

    How can we send only one message to a WCF service at a time? How we can limit the number of concurrent calls to a WCF service without use the Singleton pattern or without do the change in BizTalk Configuration file? Can we do it by Host throttling?

    Hi Pawan,
    You need to use WCF-Custom adapter and add the ServiceThrottlingBehavior service behavior to a WCF-Custom Locations.
    ServiceThrottlingBehavior.MaxConcurrentCalls - Gets or sets a value that specifies the maximum number of messages actively processing across a ServiceHost. The MaxConcurrentCalls property specifies the maximum number of messages actively
    processing across a ServiceHost object. Each channel can have one pending message that does not count against the value of MaxConcurrentCalls until WCF begins to process it.
    Follow MSDN-
    http://msdn.microsoft.com/en-us/library/ee377035%28BTS.10%29.aspx
    http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior.maxconcurrentcalls.aspx
    I hope this helps.
    Rachit
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • WCF Service and Sharepoint Form library : How i can read a access a form libray and query a item from file name and read form xml in WCF service ?

    WCF Service and Sharepoint Form library : How i can read or access a form libray and query a item from file name and read form xml in WCF service ?
    Ahsan Ranjha

    Hi,
    In SharePoint 2013, we can take use of REST API or Client Object Model to access the SharePoint objects like Form Library.
    SharePoint 2013 REST API
    http://msdn.microsoft.com/en-us/library/office/dn450841(v=office.15).aspx
    http://blogs.technet.com/b/fromthefield/archive/2013/09/05/working-with-sharepoint-list-data-odata-rest-and-javascript.aspx
    SharePoint 2013 Client Object Model
    http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
    http://msdn.microsoft.com/en-us/library/office/jj193041(v=office.15).aspx
    With the retrieved file, we can then use XmlDocument object to parse it and get the values you want:
    http://weblogs.asp.net/jimjackson/opening-and-reading-an-xml-file-in-a-document-library
    http://stackoverflow.com/questions/1968809/programatically-edit-infopath-form-fields
    Best regards
    Patrick Liang
    TechNet Community Support

  • Can't call WCF Data Service from within a WCF Service

    I am trying to query my WCF Data Service from within a WCF Service and I receive a error 404.  However, when I query the data service from my application, it works just fine.  The WCF Service will work just fine if I comment out the Data Service
    query request. 
    How do I get a WCF Service and a WCF Data Service to play nice?

    Hi,
    For this situation, first you could try to create the wcf data service and run it then consume the data service within your application by adding service reference.
    Here is an example for creating and consuming WCF Data service in console application, and for consuming the service in wcf service, you could just follow the same steps as the console application does.
    http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/introduction-to-wcf-data-service-and-odata/
    Regards

  • Create proxy to an object created by a wcf service class

    Hi
    We are trying to develop a WCF Service which is configured as per-session.
    The service object creates another object which has some data + functions, and has its own Interface which is available on both client and server.
    Is it possible to somehow create a proxy of this object on the client so that the client can call the object functions directly ?
    Thanks
    Abhishek
    PS:
    The object interface is also configured as a servicecontract and the object class is also configured as a service. However if we call this service independently, it creates a new instance of the object.

    Hi Amy
    Many thanks for replying.
    OK let me try to explain by way of example code appended after my signature.
    Let us say we have a service which implements Iservice1. The service contract has an operation returning an object of type Userinfo. In addition to data, the userinfo class has a method GetHistory which returns a datatable.
    Datacontract and Datamember attributes will cause the UserInfo object to be recreated on the client. But what I really want is a proxy to this userinfo object, so that the GetHistory function can be called directly rather than going through Iservice1.
    In general, I want the service class to be able to create a server object and then let the client have its proxy.
    Kindly advise.
    Thanks
    Abhishek
    -----Code Begins ---------------------------------
        [ServiceContract]
        public interface IService1
            [OperationContract]
            UserInfo  SelectUserDetails(UserID as Integer);
        [DataContract]
        public class UserInfo
            int userid;
            string username;
            [DataMember]
            public int UserID
                get { return userid; }
                set { userid = value; }
            [DataMember]
            public string UserName
                get { return username; }
                set { username = value; }
            public DataTable GetHistory()

  • Calling a WCF service from pl sql using a scheduler.

    Hi
    I am completely new to everything pl sql related. Right now, I need to call a WCF service method that returns a dataset. Then i need to take that dataset and insert the data into a table in the database. I want to do this by having a scheduler be called once a day.
    Does anyone have any code, examples etc?
    thanks

    And WCF stands for what? In what version of the product?
    First rule for someone new ... don't make the assumption that we can look over your shoulder or read your mind.
    What you seem to want is the built-in scheduler. The docs are at http://tahiti.oracle.com.
    Demos are at:
    http://www.psoug.org/reference/dbms_scheduler.html

  • How to get IDoc Status from WCF Service Adapter?

    I have successfully transfered a strong typed Idoc to SAP using a BizTalk WCF Service Adapter.  I did so based on this example:  [http://msdn.microsoft.com/en-US/library/cc185231(v=BTS.10).aspx].  We are using the IDoc to create a purchase order.  The IDocClient.Send(idoc, ref guid); method returns only a guid.  I can translate that using the SapAdpaterUtilities to a transaction ID.  When I look at the Idoc in WE02, I can see that it has status information which includes the purchase order number.  Is there any way for me to capture this status information in my .Net application when I send the IDoc?  Can I query the transaction ID?  Or do I just need to get the last PO Number through an RFC?
    Scott

    I ended up using the SAP .Net Data Provider in the Biztalk Adapter Pack to retrieve the PO Number.  Essentially when you pass the IDoc you won't get anything in return unless the file transfer fails.
    Scott

  • How to handle large payloads in WCF services?

    Hi All,
    I have developed WCF service,Which takes list of Employee Ids and return employee details.
    The service is working fine with 500 employee Ids but when we receive request with 5000 employee Ids the service taking much time to complete its action.
    In side the Method i am doing the following operations
    1) Each employee id i am calling stored procedure and getting the employee object and adding to list of employees
    looping through all the employeeId and contruction the list of all the employee objects
    could you please suggest us the best way /Fastest way to retreive the employee details for more than 5000 employeeIds to implement the above operation
    1) Can we use multithreading here? if possible give me an idea,
    Thanks
    Amar

    You can try using a Table Value parameter to a Stored Procedure.
    Basically:
    Create a Stored Procedure that takes the list of CustomerID's as a Table Parameter.
    Generate the Schemas using the WCF Adapter Wizard.
    Map the request message of CustomerIDs to the SQL Request message.
    In the Stored Procedure, select the customers by JOIN'ing to the Table Parameter.  In the SP, the Table Parameter will behave just like a physical table.
    Return the result set of all customers in whatever format is you need.
    This way, SQL Server is doing heavy data operation in one shot vs many individual queries.
    Here's two articles that describe how to use Table Value Parameters:
    http://msdn.microsoft.com/en-us/library/dd787869.aspx
    http://connectedcircuits.wordpress.com/2011/08/17/using-sql2008-data-table-type-biztalk-to-insert-parent-child-rows/

  • SSIS Web Service Task Error with WCF Service

    I have read all the other posts on this site and have not been able to resolve my issue.
    For testing purposes i created a very simple WCF service that takes no arguments and returns true.  That is all it does.
    When i create a winform client and instantiate the service i can run my service method and get true back so i know the service works.
    I then create a test SSIS package with 1 task, a web service task. 
    I set the web service tasks properties as follows:
    http connection: http://localhost/WCF_SSIS_Prototype/Service1.svc
    wsdl file: C:\...\SSIS_WCF_Prototype\Service1.wsdl  (I know this is not a valid path, i changed it for posting to forum)
    Service: Service1
    Method: GetData
    Variable: User::BResult
    When i run the package i get the following error:
    [Web Service Task] Error: An error occurred with the following error message: "Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException: Could not execute the Web method. The error is: Method 'ProxyNamespace.Service1.GetData' not found..    at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebMethodInvokerProxy.InvokeMethod(DTSWebMethodInfo methodInfo, String serviceName, Object connection)    at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil.Invoke(DTSWebMethodInfo methodInfo, String serviceName, Object connection)    at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread()".
    I'm not sure why it is saying "Method 'ProxyNamespace.Service1.GetData' not found.  It the web service task trying to create a proxy class and naming the proxy class namespace ProxyNamespace? 
    Any help is greatly appreciated.

    Hi,
    How  do you get around the same issue if your string type is based on a client token ?  I downloaded the .wsdl file, was able to see the service name, method and when selecting a method type, I am required to provide a client token which was given
    to me.  (Name column = clienttoken, Type = string, Value = 2227656 - ec8922 (client token numbers goes there)?  I am new to use ssis and need your help please
    error message:  Web Service Task] Error: An error occurred with the following error message:
    "Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException: The web serrvice threw an error during method execution. The error is: An error occurred
    when verifying security fro the message..   
    at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebMethodInvokerProxy.InvokeMethod(DTSWebMethodInfo methodInfo, String serviceName, Object connection)   
    at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil.Invoke(DTSWebMethodInfo methodInfo, String serviceName, Object connection) 
     at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread()"
    Thank you and regards,
    Bili

  • SPSiteCollection.Add in WCF service for FBA web application throws "user not found"

    Hi,
    I use SharePoint 2010 SP2. Programmatically I can create a FBA-based web application and now I want to add a new site collection ("/") subsequently. Everything is done in a WCF web service with its own application pool and web
    application. In extracts my code looks like this:
    const uint cLID = 1031;
    const string cSiteWebTemplate = "BLANKINTERNETCONTAINER#0";
    const string cAdminName = "i:0#.f|user|username";
    const string cDisplayName = "username";
    const string cSiteAdminEmail = "[email protected]";
    SPWebApplication webApplication = SPWebApplication.Lookup(new Uri("https://www.someurl.com"));
    using (SPSite newSite = webApplication.Sites.Add("/", "some title", "some site collection comment", cLID, cSiteWebTemplate, cAdminName, cDisplayName, cSiteAdminEmail, null, null, null, false))
    I also have a Windows forms based application where the exactly same code (except the changes required for WCF services) runs smooth, no exceptions or errors.
    Now every time the webApplication.Sites.Add-method is called inside the WCF service by any client I get the following exception (it is in German, English
    translation in square brackets):
    Microsoft.SharePoint.SPException: Der Benutzer kann nicht gefunden werden. [user cannot be found]
      bei [at] Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPContentDatabase database, SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName,
    String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, String quotaTemplate, String sscRootWebUrl, Boolean useHostHeaderAsSiteName)
      bei Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin,
    String secondaryContactName, String secondaryContactEmail, Boolean useHostHeaderAsSiteName)
      bei Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName,
    String secondaryContactEmail, Boolean useHostHeaderAsSiteName)
    The process user is the same both for my Windows forms based application and my WCF service and I expect the code runs the same in both cases. I did not find any matching forum entry and I have no idea why a WCF service does not execute
    the same way as a Windows forms application. Additionally, before applying SP2, I used an ASMX service with a similar code snippet and it also worked fine.
    Can anyone please tell me why calling
    webApplication.Sites.Add-method by a WCF service does not work? Is there anything I can do to make it work properly?

    The creation of a new web application using SharePoint API works in WCF service. I also lined out that...
    SPWebApplication webApplication = SPWebApplication.Lookup(new Uri(https://www.someurl.com));
    ... works in WCF service. In return I really get the very web application that I requested. Also exactly the same code snippet is called by exactly the same user context both in WCF Service and Windows forms application. Only for Windows forms
    application it does not throw the exception but in WCF Service it does. I had some WCF Service specialist colleague looking through the code and web.config and he stated it looks ok (unfortunately he does not have any experience with SharePoint).
    If you state "It's not, then your WCF config is wrong" what do you think I need to add or change in web.config in order to make it work? BTW: I did not modify app.config in my Windows forms application, so I thought I do not need to modify my web.config.

  • Linux + Oracle vs WCF service

    I'm having a problem between Linux /Oracle calling a WCF service.
    My client uses Oracle/Linux to send/receive data to my service, but it's using iso-8859-1 encoding, wich is not accepted by WCF (utf standard).
    I've found some solutions for this problem, but all involves DLLs installation and Windows, what is not possible with Linux.
    Unfortunately i don't know nothing about Oracle, and i don't know if it's possible to my client encode the data before sending/receiving to me.
    I'd appreciate some help.
    Thanks!

    The linux client can continue sending the data as it pleases (i.e., in iso-8859-1), and the encoder, used on the server only, would be able to read it. The encoder then can decide how to encode the response back to the client (UTF-8 or iso-8859-1 again).
    If you want the response to be in iso-8859-1 as well you may also need something like a message inspector to update the content-type header with the appropriate charset.
    Update: example with the custom encoder using ISO-8859-1
    public class StackOverflow_7033442 {     [ServiceContract] public interface ITest {         [OperationContract] string Echo(string text); } public class Service : ITest {         public string Echo(string text)         {             return text;         } } public static void Test() {         string baseAddress = "http://" + Environment.MachineName + ":8000/Service";         ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));         CustomBinding binding = new CustomBinding(             new CustomTextMessageBindingElement("iso-8859-1", "text/xml", MessageVersion.Soap11),             new HttpTransportBindingElement());         host.AddServiceEndpoint(typeof(ITest), binding, "");         host.Open();         Console.WriteLine("Host opened");          string request = @"<?xml version=""1.0"" encoding=""iso-8859-1""?> <s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">   <s:Body>     <Echo xmlns=""http://tempuri.org/"">       <text>Hello áéíóú</text>     </Echo>   </s:Body> </s:Envelope>";         HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(baseAddress);         req.Method = "POST";         req.ContentType = "text/xml; charset=iso-8859-1";         req.Headers["SOAPAction"] = "http://tempuri.org/ITest/Echo"; Stream reqStream = req.GetRequestStream(); Encoding encoding = Encoding.GetEncoding("iso-8859-1"); byte[] reqBytes = encoding.GetBytes(request); reqStream.Write(reqBytes, 0, reqBytes.Length); reqStream.Close(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Console.WriteLine("HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription); foreach (var header in resp.Headers.AllKeys) {             Console.WriteLine("{0}: {1}", header, resp.Headers[header]); } if (resp.ContentLength > 0) { Console.WriteLine(new StreamReader(resp.GetResponseStream(), encoding).ReadToEnd()); } Console.Write("Press ENTER to close the host"); Console.ReadLine(); host.Close(); } #region Custom Text Message Encoder sample, verbatim public class CustomTextMessageEncoder : MessageEncoder { private CustomTextMessageEncoderFactory factory; private XmlWriterSettings writerSettings; private string contentType; public CustomTextMessageEncoder(CustomTextMessageEncoderFactory factory) { this.factory = factory; this.writerSettings = new XmlWriterSettings(); this.writerSettings.Encoding = Encoding.GetEncoding(factory.CharSet); this.contentType = string.Format("{0}; charset={1}", this.factory.MediaType, this.writerSettings.Encoding.HeaderName); } public override string ContentType { get { return this.contentType; } } public override string MediaType { get { return factory.MediaType; } } public override MessageVersion MessageVersion { get { return this.factory.MessageVersion; } } public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType) { byte[] msgContents = new byte[buffer.Count]; Array.Copy(buffer.Array, buffer.Offset, msgContents, 0, msgContents.Length); bufferManager.ReturnBuffer(buffer.Array); MemoryStream stream = new MemoryStream(msgContents); return ReadMessage(stream, int.MaxValue); } public override Message ReadMessage(Stream stream, int maxSizeOfHeaders, string contentType) { XmlReader reader = XmlReader.Create(stream); return Message.CreateMessage(reader, maxSizeOfHeaders, this.MessageVersion); } public override ArraySegment<byte> WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset) { MemoryStream stream = new MemoryStream(); XmlWriter writer = XmlWriter.Create(stream, this.writerSettings); message.WriteMessage(writer); writer.Close(); byte[] messageBytes = stream.GetBuffer(); int messageLength = (int)stream.Position; stream.Close(); int totalLength = messageLength + messageOffset; byte[] totalBytes = bufferManager.TakeBuffer(totalLength); Array.Copy(messageBytes, 0, totalBytes, messageOffset, messageLength); ArraySegment<byte> byteArray = new ArraySegment<byte>(totalBytes, messageOffset, messageLength); return byteArray; } public override void WriteMessage(Message message, Stream stream) { XmlWriter writer = XmlWriter.Create(stream, this.writerSettings); message.WriteMessage(writer); writer.Close(); } } public class CustomTextMessageEncoderFactory : MessageEncoderFactory { private MessageEncoder encoder; private MessageVersion version; private string mediaType; private string charSet; internal CustomTextMessageEncoderFactory(string mediaType, string charSet, MessageVersion version) { this.version = version; this.mediaType = mediaType; this.charSet = charSet; this.encoder = new CustomTextMessageEncoder(this); } public override MessageEncoder Encoder { get { return this.encoder; } } public override MessageVersion MessageVersion { get { return this.version; } } internal string MediaType { get { return this.mediaType; } } internal string CharSet { get { return this.charSet; } } } public class CustomTextMessageBindingElement : MessageEncodingBindingElement, IWsdlExportExtension { private MessageVersion msgVersion; private string mediaType; private string encoding; private XmlDictionaryReaderQuotas readerQuotas; CustomTextMessageBindingElement(CustomTextMessageBindingElement binding) : this(binding.Encoding, binding.MediaType, binding.MessageVersion) { this.readerQuotas = new XmlDictionaryReaderQuotas(); binding.ReaderQuotas.CopyTo(this.readerQuotas); } public CustomTextMessageBindingElement(string encoding, string mediaType, MessageVersion msgVersion) { if (encoding == null) throw new ArgumentNullException("encoding"); if (mediaType == null) throw new ArgumentNullException("mediaType"); if (msgVersion == null) throw new ArgumentNullException("msgVersion"); this.msgVersion = msgVersion; this.mediaType = mediaType; this.encoding = encoding; this.readerQuotas = new XmlDictionaryReaderQuotas(); } public CustomTextMessageBindingElement(string encoding, string mediaType) : this(encoding, mediaType, MessageVersion.Soap11WSAddressing10) { } public CustomTextMessageBindingElement(string encoding) : this(encoding, "text/xml") { } public CustomTextMessageBindingElement() : this("UTF-8") { } public override MessageVersion MessageVersion { get { return this.msgVersion; } set { if (value == null) throw new ArgumentNullException("value"); this.msgVersion = value; } } public string MediaType { get { return this.mediaType; } set { if (value == null) throw new ArgumentNullException("value"); this.mediaType = value; } } public string Encoding { get { return this.encoding; } set { if (value == null) throw new ArgumentNullException("value"); this.encoding = value; } } // This encoder does not enforces any quotas for the unsecure messages. The // quotas are enforced for the secure portions of messages when this encoder // is used in a binding that is configured with security. public XmlDictionaryReaderQuotas ReaderQuotas { get { return this.readerQuotas; } } #region IMessageEncodingBindingElement Members public override MessageEncoderFactory CreateMessageEncoderFactory() { return new CustomTextMessageEncoderFactory(this.MediaType, this.Encoding, this.MessageVersion); } #endregion public override BindingElement Clone() { return new CustomTextMessageBindingElement(this); } public override IChannelFactory<TChannel> BuildChannelFactory<TChannel>(BindingContext context) { if (context == null) throw new ArgumentNullException("context"); context.BindingParameters.Add(this); return context.BuildInnerChannelFactory<TChannel>(); } public override bool CanBuildChannelFactory<TChannel>(BindingContext context) { if (context == null) throw new ArgumentNullException("context"); return context.CanBuildInnerChannelFactory<TChannel>(); } public override IChannelListener<TChannel> BuildChannelListener<TChannel>(BindingContext context) { if (context == null) throw new ArgumentNullException("context"); context.BindingParameters.Add(this); return context.BuildInnerChannelListener<TChannel>(); } public override bool CanBuildChannelListener<TChannel>(BindingContext context) { if (context == null) throw new ArgumentNullException("context"); context.BindingParameters.Add(this); return context.CanBuildInnerChannelListener<TChannel>(); } public override T GetProperty<T>(BindingContext context) { if (typeof(T) == typeof(XmlDictionaryReaderQuotas)) { return (T)(object)this.readerQuotas; } else { return base.GetProperty<T>(context); } } #region IWsdlExportExtension Members void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context) { } void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { // The MessageEncodingBindingElement is responsible for ensuring that the WSDL has the correct // SOAP version. We can delegate to the WCF implementation of TextMessageEncodingBindingElement for this. TextMessageEncodingBindingElement mebe = new TextMessageEncodingBindingElement(); mebe.MessageVersion = this.msgVersion; ((IWsdlExportExtension)mebe).ExportEndpoint(exporter, context); } #endregion } #endregion }

  • ERROR_NOT_FOUND: there is no credentials associated with the given resource name. + WCF Service while Retrieving WindowsCredentials

    Hi guys,
    I am struck with a problem while retrieving the Windows Credentials from WCF service.
    1. I have used WSHttpBinding.
    2. I have configured the Website and App pool to run under a specific user who is an Administrator for the server.
    3. I have created the windows Credential of Generic type using Credential manager with the same user.
    4. I configured the Website to allow only Anonymous and Windows Authentication in IIS (IIS Version: 8.5).
    5. I tried the same code in the same server by logging into server with same user and debug the service. The service is returning the windows Credential requested.
    6. But i am unable to retrieve the Windows Credentials from the same code when published in IIS in the same server.
    i configure the Security in Server and client as below:
       <bindings>
          <wsHttpBinding>
            <binding name="wsHttpEndpointBinding">
              <security mode="Transport" >
                <transport clientCredentialType="Windows"/>            
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
    7. I tried to read the error code generated by Credential Manager API from  my code and it returned the below error when i am accessing the deployed service.
    ERROR_NOT_FOUND: there is no credentials associated with the given resource name.
    8. I have also checked this with other environments out side my virtual machine with the same code and config file. All environments it is working fine except my environment. Can any body help me out on this...

    Hi pavan kumar,
        As per this case, I have shared the details below :
    1.where you got stuck & receive error message whether in service side or client side ?
    2.if its in service side, then I suggest you to enable tracing on wcf service for debugging purpose to findout the root cause.
    3.For configure tracing refer here "https://msdn.microsoft.com/en-us/library/ms733025.aspx"
    4.To know about WCF Extensibility – System.Diagnostic Tracing ,then refer the below link
    http://blogs.msdn.com/b/carlosfigueira/archive/2011/08/02/wcf-extensibility-system-diagnostic-tracing.aspx
    5.If its in Client side, Please make sure that the client is in the same or trust domain as service. 

Maybe you are looking for

  • Error while renaming column in Apex 3.2.1

    Hi, I am getting the following error while renaming column in Oracle Apex 3.2.1 through SQL workshop: "ORA-24344: success with compilation error" Interestingly, it only gives an error when I rename the column again to its original name. For example,

  • My bran new Mac Pro, won't recognize my external hard drive?

    Hello,      I just got the new mac pro about a month ago (the cylindrical kind) it has 16 MGs of ram and 250 GBs. I got a 2 TB external hard drive for time machine, and i already have a 500 GB portable hard drive for transferring files. They worked f

  • Call disconnect on FXO port

    Hi All, I have an issue with call disconnect on FXO port. Call are getting disconnected as soon as it connects. I observed the call takes the port 0/20 which has the command supervisory disconnect anytone but in other ports I see supervisory disconne

  • Upgrade Oracle from Oracle9i to Oracle 10g

    Hi, We will be having a project on upgrading the existing version of Oracle 9i to 10g. Our application uses Java as the front end and Oracle as the backend. So if anyone has done similar kind of Oracle upgrade from 9i to 10g, could you please tell us

  • Deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE

    How can deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE in SQL?