WCF / ASMX :: Publish Enum Through Web Service Without Being Param/return Type?

Apr 30, 2010

I have a webmethod that has three parameters:

public AuthenticationResult Authenticate(Enum type, string userName, string password) But the problem I had is that if a null/invalid enum is entered for the type variable it throws an error message.

So the obvious solution is to use a string/int instead but I am cannot do this as current users already use the existing webmethod.

So i was thinking:

public AuthenticationResult Authenticate(object type, string userName, string password) and handling the casting myself but the problem I had with this is that now my users do not have access to the Enum type.

So my question is can I publish the enum type without having it as a parameter/return value? Allow the client to access the Enum so they can pass it into the method. Would using a method that returned a type that was my enum work? Or is there a way to catch this custom error: (I dont think so as it appears to be on the client end when converting Enum to xml). The error is: (System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Instance validation error: '45465' is not a valid value for Enum.)

View 1 Replies


Similar Messages:

C# - ASMX Web Reference Not Updating After Service Return Type Updated?

Feb 21, 2010

I have a webservice - called MyCompany.WebService1

I reference this using a web reference in my ASP.net web application.

Theres a method called "GetDeal" in this web service, that returns a "Deal" Object.

The deal object currently looks (for example) like this:

[code]....

This class is in a different assembly: MyCompany.Model

The web service references this assembly.

In my web app, I can call the GetDeal method. This returns Service1.Deal (service1 is just the name of the web reference)

I can access both properties above. I have now changed the Deal class, and added a couple more properties.

However, I can't see these new properties in my web application. I've updated the web service in the web application. I rebuilt the web service several times, tried removing the MyCompany.Model reference and re-addding it etc...

I can't figure out what has changed... This was working - I have changed the model before, and it's updated the reference correctly...

View 2 Replies

WCF / ASMX :: Svcutil Generates Underscores In Enum With Type Int?

Feb 8, 2011

i am generating a wcf data contract from a schema, using svcutil /d: option, however the enum of type xsd:int in schema is generating all the values as ints, with underscores, obviously to make valid code. How can i get the actual value of 1000

E.g Enum Impact with values 1000,2000,3000 generates code

public enum Impact : int
{
[System.Runtime.Serialization.EnumMemberAttribute(Value = "1000")]
_1000 = 1,
[System.Runtime.Serialization.EnumMemberAttribute(Value = "2000")]
_2000 = 2,
[System.Runtime.Serialization.EnumMemberAttribute(Value = "3000")]
_3000 = 3
}

View 2 Replies

WCF / ASMX :: How To Publish A Service With Authentication

Feb 10, 2011

how to publish a service with authentication

View 2 Replies

WCF / ASMX :: Publish A Web Service From A Wsdl File

Aug 8, 2010

I have a wsdl file which are the definition of several methods of the web service associated . I want to create this web service in order to consume it through a Java web service client.How i could do this?

View 1 Replies

WCF / ASMX :: Web Service - Return XML

Jun 10, 2010

I have a web service that originally returned a string containing text formatted as XML. I was contacted by the programmer who is going to be consuming the web service, and he asked if I could make it "just XML" and not a string. I converted the web service so that it returns an XMLDocument object, and it seems to be returning data properly. I would just like to erify, however, that the XMLDocument object is what the other programmer was referring to when he said "just XML," and that the XMLDocument can be universally consumed by any programmer, regardless of his or her programming environment.

View 4 Replies

WCF / ASMX :: Return More Than One Value From Web Service

Oct 13, 2010

I am new to web service... I have created a simple web service to add a record to sql server by passing a parameter and returns true or false once done. It the same time, I want to return the customer_account_number value created on the sql server.. so basically I want to return the true and false and one (or more) additional values.

View 5 Replies

C# - Web Service Return Type Exception?

Jul 26, 2010

I have a web service and its methods return a class which is name WSResult. WSResult has 2 properties. One of property's type is int and the other one's type is object. I want to return some different type with this second property.

[code]....

How can i pass an object which i retrieved from other web services or that i generated from my serializable classes inside M_ResultObject property ?

View 2 Replies

Return Pure XML From Asmx Web Service?

May 6, 2010

I want an asmx webservice with a method GetPeople() that returns the following XML (NOT a SOAP response):

<People>
<Person>
<FirstName>Sara</FirstName>
<LastName>Smith</LastName>
</Person>
<Person>
<FirstName>Bill</FirstName>
<LastName>Wilson</LastName>
</Person>
</People>

View 4 Replies

WCF / ASMX :: Regarding Web Service Return Types?

Jun 24, 2010

i have 10 employee objects.I want to return these 10 object from a web method to web service client.

View 6 Replies

C# - Mocking Method Call With Out Param And No Return Value In Rhino Mocks?

Feb 9, 2010

So I've got this method called LoginUser:

public void LoginUser(out SystemUser userToLogin, string username)

Having just started with Rhino Mocks, I'm having a little trouble mocking a call and return value from this method while testing my Presenter code. What's the correct syntax in this instance?

View 1 Replies

WCF / ASMX :: How To Return XML Structure From A Web Service In Page

Mar 24, 2011

I have a problem to connect my ASP page with a Web Service.

I'm going to explain the situation:

VB: WEB SERVICE: service1.asmx.vb (http://localhost:1234/Service1.asmx)

[Code]....

FROM ASP page

I have not any problem to receive the string from the SECOND function

However, When I call the FIRST one I receive an error:

"Microsoft VBScript runtime error (0x800A01C2) the wrong number of arguments or invalid property value argument"

I use this object: recXML = CreateObject("Msxml2.DOMDocument")

View 2 Replies

WCF / ASMX :: Max Return Size Of String From Web Service?

Feb 14, 2011

I have a web service that is declared like this.

[Code]....

Function inside the service simply returns string separated by some delimitor. This string is then used by JS function to assign to a jQuery datatable. Is there a maximum limit on size of this string? I have about 2000 rows with 6 columns each. I get an error (failed handle) when I return them all. But if I do only top 500, it works fine.Is there any size limitation?

[WebService(Namespace = "http://tempuri.org/")]

View 8 Replies

WCF / ASMX :: Return JSON Data From A 2.0 Web Service?

Sep 10, 2010

Just ramping up on JSON and JQuery and returning data to a ASP.NET web page from a web service using Ajax. The JQuery part is pretty straight-forward. However, when trying to return JSON formatted data instead of XML from a 2.0 web service, I'm stuck. The web service does have the System.Web.Script.Services.ScriptService attribute, so I can hit it via JavaScript; however, the web service always...always...returns data in XML format, no matter if I explicitly say I want JSON as the datatype in my JQuery code. So I don't know if this is an issue with the web service or the JQuery code. I posted this here, but realize that the category could be incorrect depending on where the issue is. Is there no way to return JSON data from a 2.0 web service? It's a production web service, so I can't change the code unfortunately.

View 3 Replies

WCF / ASMX :: WCF Data Service Out Put Not Return Correctly?

Sep 28, 2010

I am consuming wcf Data service in client application following way, when i execute SP, some of the columns are repeating with same value,

DataServiceContext context1 = new DataServiceContext(new Uri(serviceURL));
string strparam = "emailid='" + paramemail + "'& LocalTitle='" + paramtitle + "'& ColorGrouping='" + paramcolor + "'";
string url = serviceURL + "GetSearchResult?" + strparam; [code]....

View 3 Replies

AJAX :: Use Return JSON Object From Web Service As A Declared Type?

Jan 3, 2010

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.

View 3 Replies

WCF / ASMX :: How To Write A Service To Return The Filenames Starting With A String

Feb 6, 2011

I have number of files stored in a folder.

I want to write a wcf service to ruturn a list of filenames based on the text typed in a text box.

The structure of the method i need is something like this :

[Code]....

The requirments is to return only the filenames that starts with the typed text. Only the file name part is required not the full path.

View 3 Replies

WCF / ASMX :: Change Response Type In WSE 3.0 Service

Mar 24, 2011

I inherited a old WSE 3.0 service. I am building an ASP.NET client for it. It is returning a MTOM response so my client is complaining. Does anyone know of a way to change the response type to XML? Or change my client to accept MTOM? I just want this crap to work.

View 2 Replies

WCF / ASMX :: Web Service Parameter Type Changed?

Aug 6, 2010

So I have a class library project, a web service project and a website project.

In both the web service project and website project, I make a reference to the class library project, then in the website project I make web reference to the web service in my localhost.

So my web service project have the below web method

<WebMethod()> Public Function HelloWorld(ByVal tempClass As testSolutionClassLibrary.Class1) As String

Return "Hello World"

End Function

I don't understand why when I try to call the above web method from my website project, the parameter change from "testSolutionClassLibrary.Class1" to "testSolutionWebServiceRef.Class1"? Shouldn't it remain as "testSolutionClassLibrary.Class1"?

View 1 Replies

WCF / ASMX :: Parser Error Message: Could Not Create Type 'Service'

Sep 24, 2010

My web service works fine on my local machine but when i put it on the server it throw this error:

Parser Error Message: Could not create type 'Service'.

I don't know how to fix this.

View 1 Replies

WCF / ASMX :: How To Serialize Enum To Its Value

Feb 12, 2011

I am facing an critical problem in Enum serialization in WCF. Here is the scenario: I have an enum like this...

[Serializable] [DataContract(Namespace = "http://www.geniusdoc.portal.com/serivces/2011/v1/GdService", Name = "AppointmentMode")] public enum AppointmentMode : int { // 1: Email, 2: Phone [EnumMember(Value = "1")] None = 1, [EnumMember(Value = "2")] Email = 2, [EnumMember(Value = "3")] Phone = 3 }

Here I decorated each enum value with [EnumMember], so that I can use the Enum as Data Contract in WCF.
And, AppointmentMode will be saved as INTEGER in database. So I need to serialize this Enum to its value. So I have specified value to each member like... [EnumMember(Value = "1")]

Problems:

If I use the above code as it is...SvcUtil not considering Enum Text, and generating the Enum in Proxy as below...
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="AppointmentMode", Namespace="http://www.geniusdoc.portal.com/serivces/2011/v1/GdService")] public enum AppointmentMode: int { [System.Runtime.Serialization.EnumMemberAttribute(Value="1")] _1 = 1, [System.Runtime.Serialization.EnumMemberAttribute(Value="2")] _2 = 2, [System.Runtime.Serialization.EnumMemberAttribute(Value="3")] _3 = 3, }
If I remove the Value from [EnumMember(Value = "1")], while deserialization is considering Enum Text, and giving results as below
<AppointmentMode>None</AppointmentMode>

Expected result:

1. Enum in the Client proxy should be same original Enum.
2. Enum Deserialization should consider EnumValue, such a way that it will return
<AppointmentMode>1</AppointmentMode>

How to get this done?

View 5 Replies

WCF / ASMX :: Return Dynamic / When Returns To Aspx Error At Aspx(no Exception Gets Caught At  @ Service)?

Feb 9, 2011

In our project WCF service is acting as our BLL.

i had scenario where i had to fill list of object class without knowing its type see code:

Added contract

[OperationContract]
dynamic GetReferenceTableData(string tableName);

method in service:

public dynamic GetReferenceTableData(string tableName)
{
try
{
dynamic tableData = ReferenceTableDAL.GetReferenceTableData(tableName);
return tableData;
}
catch (Exception ex)
{
throw;
}
}
method at DAL(ReferenceTableDAL):
public static dynamic GetReferenceTableData(string tableName)
{
Database db = DatabaseFactory.CreateDatabase(Flags.ConnectionStringKey);
DbCommand dbCommand = db.GetStoredProcCommand("USP_GETTABLEDATA");
dynamic objDynamic = null;
if (tableName.ToLower() == "a")
{
objDynamic = new List<A>();
}
else if (tableName.ToLower() == "b")
{
objDynamic = new List<B>();
}
else if (tableName.ToLower() == "c")
{
objDynamic = new List<C>();
}
try
{
db.DiscoverParameters(dbCommand);
dbCommand.Parameters["IN_TABLENAME"].Value = tableName;
DataSet dsTableData = db.ExecuteDataSet(dbCommand);
if (tableName.ToLower() == "a")
{
foreach (DataRow dataRow in dsTableData.Tables[0].Rows)
{
objDynamic.Add((A)dataRow);
}
}
else if (tableName.ToLower() == "b")
{
foreach (DataRow dataRow in dsTableData.Tables[0].Rows)
{
objDynamic.Add((B)dataRow);
}
}
else if (tableName.ToLower() == "c")
{
foreach (DataRow dataRow in dsTableData.Tables[0].Rows)
{
objDynamic.Add((C)dataRow);
}
}
}
catch (Exception ex)
{
throw;
}
return objDynamic;
}
@ Aspx
try
{
using (DataServiceRef.DataServiceClient petService = new DataServiceRef.DataServiceClient())
{
dynamic tableData = petService.GetReferenceTableData(tableName);
//tableData is null ,exception
}
}
catch (Exception ex)
{
throw;
}

There is no exception at dal or service end when i debug list gets filled ok but when returns to aspx error at aspx(no exception gets caught at @ service) but exception at aspx i.e:

Message:The underlying connection was closed: The connection was closed unexpectedly.
Stack Trace: at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

View 3 Replies

C# Trying To Serialize An Enum Type Serverside And Then Output It In Clientside JavaScript

Jun 18, 2010

Let's say I have a function that takes a string. That string contains the fully name of an enum type (e.g. "MyCompany.Area.AotherNamespace.MyEnum").

How could I create an array of strings (or List<string>) whose elements are the values of MyCompany.Area.AotherNamespace.MyEnum?

Is that even possible?I'm basically trying to serialize an enum type serverside and then output it in clientside JavaScript so I don't have to define an enum in two places--in my C# and my JavaScript.

View 1 Replies

C# - Specified Cast Is Not Valid. Enum / Try Also Enum.Parse But Didnt Work?

Sep 28, 2010

whats wrong with this code, i try also Enum.Parse but didnt work.

public enum RoleNames
{
Administrator,

[code]...

View 1 Replies

WCF / ASMX :: Enum Mapper - C# 3.5 / Easiest Way To Achieve Mapping Without Writing Tedious Switch Statements?

May 25, 2010

We are developing SOA based application using .NET 3.5 and WCF & WPF.

One common issue we are facing is mapping between WCF enum and WPF enums. We had to do mapping between WCF enums to WPF enums. Following is sample code

Switch(WCFServiceObject.Status)
{
Case WCFServiceStatus.Married[code]....

You can see that we have to do mapping WPF and WCF enums. Is there any easiest way to achieve this mapping without writing tedious switch statements? One way of doing this is using Dictionary, but apart from this, is there any good way? We have lots of enums for which have to do mappings.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved