.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

passing XMLDocument object as input to WCF service

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :WCF


i have to write a WCF service which accepts XMLDocument object as input.

In my contract, I have defined a function like this:

bool validate(XmlDocument doc);

In my service, the function is implemented llke this:

public bool validate(XMLDocument doc)


code to validate the doc against an XSD file

From my test project i am passing an XML document.

But it says service cannot be found.

Instead if i define XMLDocument doc inside function like this:

public bool validate()


XMLDocument doc= path of document

code to validate the doc against an XSD file

and contract like this:

bool validate();

it works fine.

It validates the XML against an XSD and returns true or false.

Please help.

View Complete Post

More Related Resource Links

passing messageContract object to a WCF Service method using Soap - not as a method parameter

i want a web application to create a service reference to my WCF service, insert information to the header of the soap call and call my WCF method. my WCF supports soap operations (also there is an endpoint in the config). i read about MessageContract attribute and declared one in the interface file: [ServiceContract] public interface IBasicService { [OperationContract] [WebGet(UriTemplate = "GetData?value={value}")] // Add support for HTTP GET Requests string GetData(int value); } [MessageContract] public class BasicServiceHeader { [MessageHeader] public string myString; } the implementation of the contract : public class BasicService : IBasicService { public string GetData(int value) { return string.Format("You entered: {0}", value); } } i don't want the BasicServiceHeader to be passed as a parameter of GetData function , i want to keep the function signature as it is (without a BasicServiceHeader parameter) and to extract the BasicServiceHeader inside the function, (just like using soapHeader) can i do that ?

Passing an object with a TimeSpan field to web service resets the TimeSpan to 00:00:00


Hello all,


I have a web service that takes a TaskGroupRecord object as a parameter. This object is defined as:

  public class TaskGroupRecord
    public Guid TaskGroupID { get; set; }
    public string Name { get; set; }
    public DateTime StartDate { get; set; }
    public TimeSpan Duration { get; set; }
    public RepeatSchedule Schedule { get; set; }

    public TaskGroupRecord()
      //TaskGroupID = Guid.Empty;
      //Name = string.Empty;
      //StartDate = DateTime.MaxValue;
      //Duration = new TimeSpan();

Passing an exception object to a WCF service


I'm pretty new to WCF , as an experiment I was trying to create a WCF service wrapper over an exception handler class which is using the enterprise library underneath.

I created a simple class with one exception variable, which gets exposed as the data contract

when I try to pass the exception to the WCF service I get the following serialzation error

There was an error while trying to serialize parameter http://tempuri.org/:ex. The InnerException message was 'Type 'System.Collections.ListDictionaryInternal' with data contract name 'ArrayOfKeyValueOfanyTypeanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

I configured the app.config for the calling application by adding Syste.Exception as known type in the DataContractSerializer

        <add type="System.Exception, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <knownType type="System.Exception, mscorlib, Version=, Cult

passing object values from server to client problem


I get a message that x_login is not declared.  I added Dim login as String = "123", but that didn't help.  What's the problem?

code behind....

Dim Login = "123"
x_login.Value = loginID


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="simForm" runat="server" method='post' action='https://test.authorize.net/gateway/transact.dll'>
        <input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
        <input type='hidden' runat="server" name='x_login' id='x_login' />
        <input type='submit' runat="server" id='buttonLabel' />



Object expected error


<input type="button' onclick="timeoutCheck()" value="Click Me!" />

it tells me Microsoft JScript runtime error: Object expected


timeoutCheck() is my script function that i declared above the input tag

can anyone tell me why i am getting this error

hello i need help , any ideas are welcome i have been working on this for two weeks now and cannot seem to be able to advance

Problem with passing an Image as binary through web service



I have a web service that is accessed by a windows forms application and receives updates like facility name, address, image etc. Everything works fine except the image data is not being passed to the windows app. I am saving the images in database on both sides, so when I pull it from the server I use the following code

if (!reader.IsDBNull(floorPlanOrdinal))

facility.FloorPlan = (byte[])reader["FloorPlan"];

I can see the facility.FloorPlan Dimentions as 103840 when I debug this method which means that the data is pulled from the database fine.

On the forms side though the dimentions become 0, all other values pass fine except this. Here is the facility property in the web service on server side.

using System;

using System

Problem passing custom object returned by the same webservice among two separate projects

I am running into casting issue with this scenario: 1. I made a custom object lets call it EmployeeObject.  2. The Employee object is wrapped in the EmployeeWebservice.  3. I have a client application project lets call it EmployeeClientApplication and a class library called DoSomeWorkClassLibrary.  Both EmployeeClientApplication and DoSomeWorkClassLibrary reference the EmployeeWebService and need to be able to pass the EmployeeObject back and forth.  4. The EmployeeClientApplication also references the DoSomeWorkClassLibrary. 5. The employeeObject in the EmployeeClientApplication becomes EmployeeClientApplication.EmployeeWebService.EmployeeObject. 6. The employeeObject in the DoSomeWorkClassLibrary becomes DoSomeWorkClassLibrary.EmployeeWebService.EmployeeObject. 7. The DoSomeWorkClassLibrary has a method called DoSomeWork that takes an EmployeeObject. When I try to pass employeeObject from EmployeeClientApplication to DoSomeWorkClassLibrary by doing something like this: DoSomeWorkClassLibrary.DoSomeWork(EmployeeClientApplication.EmployeeWebService.EmployeeObject), I am getting Unable to convert EmployeeClientApplication.EmployeeWebService.EmployeeObject to DoSomeWorkClassLibrary.EmployeeWebService.EmployeeObject.  I have searched high and low to fix this issue, I have tried changing the namespace of the reference.cs file of the webservice in

Passing return value from a Web Service to a label in a Form View

I am using JavaScript to call a web service. The JS is correctly receiving and passing the web service information. At the moment, the web service returns a country name as a string to a JavaScript alert pop up box as follows:ret = CountryRegionsWebService.GetTranslatedCountryShortName(ddl1_value, ddl2_value, OnComplete, OnTimeOut, OnError);function OnComplete(args) { alert(args); } I want to change this so that web service returns the country name to a label inside an insert item template of a form view. Is there a way to pass in the label variable to the OnComplete function signature and still account for the variable args?, such as: Server Side Declaration of JavaScript ddl2.Attributes.Add("onChange", "JavaScript:OnComplete('" + lab5.ClientID + "', '" + "args" + "');"); Client Side JavaScript function OnComplete(lab5_id, args) { var lab5 = document.getElementById(lab5_id); lab5.innerHTML = args; }  

Passing parameter into Web Service

Hi, I'm creating a web service using C#, and wondering if it is possible to capture the parameter passed in from the URL?e.g. http://www.abc.com/webservice/service.asmx?para1=one&para2=twoIs there a function or something that can obtain the parameters like the normal Request.QueryString? Thanks in advance! Rgds

MCTS 70-503 Practice exam about service object instancing

The question says the default behavior for instancing service object is that each instance is associated with one user-defined service object, but in the book, 'MCTS Self Training Kit', it is said that the default behavior is PerCall. Is this a bug in the practice exam?

Passing Parameters to Web Service Method using XML DataSource

I would like to know how to pass parameter values to a web service that I am using as a data source.  I am using the Data Source Type XML.  I have been able to retrieve data back from the web service method that does not require parameters.  But I need to be able to use a web service that requires parameter values.  How do you use the XML data source type with parameters?  I have use information from the article  http://www.codeproject.com/KB/reporting-services/SSRS2005XML.aspx. thanks, Lloyd

Passing GetObjectContext from WCF service to COM

Hi, I am trying reuse COM component in my existing application(ASP,COM).Com is using GetObjectContext and the stored session information to create the Objects inside the COM. How can set the GetObjectContext in WCF application. tried below code  in WCF but ctx is null Dim ctx As COMSVCSLib.ObjectContext Dim objAppServer As New COMSVCSLib.AppServer ctx = objAppServer.GetObjectContext()     Thanks in advance  

web service task input

Hi, I just searched forum and cannot find what I need. From web site for web service calling from SSIS step by step, I setup http connection, and download WSDL file with no problem. I then go to input part to select service and method. After method chosen, I can see 3 parameter variables as all string type. They told me that 1 variable is input string, the other variables are output strings. The main task is to use web service to call the method to pass XML file. I want to know should I create 3 project level variables to hold as corresponding 3 parameter variables? Does it mean that I should copy all XML file content to input parameter variable? How can I see the ouptut value of parameter variables? For output part, I created new file as output.xml file. After package run, it shows me "<Result>The result is null. Either the result is null or the Web method returns void.</Result> ". What does this mean? Thanks for any info or help!

syntax problem passing parameter into Indexing Service Query

Hi everyone, I have the following query which works fine: select OriginalFileName from Document_Entries where EntryType like 'File%' and substring(entry,charindex('file_',entry),LEN(entry)) in (  SELECT filename FROM OPENQUERY(MySearchCat, 'SELECT Directory, FileName FROM SCOPE() WHERE    CONTAINS('' "green" '') ') )  It finds all documents in the document system which contain the word "green" using the index catalog.  My problem is that i need to include this query in a larger stored procedure which accepts a parameter for key words amongst others. I can't work out the syntax to get the @keywords parameter into query. The closest I've come is the following which runs but comes back with "incorrect syntax near keyword 'green'".  The @keywords parameter will contain any key words the user enters.   declare @keywords nvarchar(500) set @keywords='green'   Declare @query nvarchar(max) set @query = ' select OriginalFileName from Document_Entries where EntryType like ''File%'' and substring(entry,charindex(''file_'',entry),LEN(entry)) in (  SELECT filename FROM OPENQUERY(MySearchCat, ''SELECT Directory, FileName FROM SCOPE() WHERE    CONTAINS(''' + @keywords + ''') '')     )  )' exec(@query)   Any ideas? thanks Gus

How to use return JSON object from web service as a declared Type?

Hi, I just hit the following issue: I am calling a web service that returns a serialized JSON object let's say: __type, FirstName, LastName (.net object Person with properties FirstName and LastName). __type's value is Test.Person I have created a JS object using Type.registerNameSpace/registerClass called Demo.Person and it is registered on the page using the ScriptManager. Everything is working fine; I am able to get data from the server on the call back. Is it possible to make the returned object from the web service be an instance of the declared JavaScript Demo.Person class? The idea would be to call a method like result.getFullName() on the client side without having to copy all the properties. This is just a simple scenario for more complex objects.   Thanks,   Teo

Passing List to WCF Service

Hi, All, I'm not sure this has been covered before.  I did search, but not sure that any of those responses apply: I'm relatively new to WCF. I have the following classes:  PostAddress, EmailAddress, PhoneNumber, ContactInformation and, Person.  The ContactInformation contains each a List<PostAddress>, List<EmailAddress>, List<PhoneNumber> property.  The Person class has a ContactInformation property. When I pass my Person object to my WCF service, my ContactInformation Lists values are null.  For example: I create an address with: street, city, state, zip, country and add it to my List<PostAddress> I add the list to the Person's ContactInformation's List<PostAddress> Property I pass it to the WCF Service.  At that time, I have this: Person.ContactInformation.Addresses.Count = [the number of addresses in the list] Person.ContactInformation.Addresses[index].property = null My service inferface looks like this (I haven't fully sketched it all out yet): [   ServiceContract]     public interface IMyService { [   OperationContract]     bool FoundDuplicate( Person p ); [   OperationContract]     void SubmitNewMembership( Person p, Membership m ); } I'm using Visual Studio Ultimate 2010/.NET 4 on Windows 7 Professional Edition if that

Web Service and JSON input data

Hy, I'm try to build a web service who can get in input a JSON string. My web method is: [WebMethod(Description = "Edit Entity")][System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]public string ManageEntity(string _DataIn){ // System.Diagnostics.Debug.WriteLine(_DataIn);            return "{\"Result\":\"OK\"}";} When I try posting some data to the webservice I get the error "No parameterless constructor defined for type of 'System.String'". Why the system try to deserialize my JSON string? Is possible to simple retrieve the string? Thanks Lorenzo SonciniLorenzo Soncini
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend