C# - Passing File From Web Page To Wcf Service?

Nov 26, 2010

We have a asp.net page where the user is allowed to upload a file. This file is then sent on to a back end system via a wcf services. Currently we read the file into a byte array and then send an object into the wcf service where the byte array is a property. This works fine, but we are wondering if there is a more efficient way to do it?

View 1 Replies


Similar Messages:

Passing Multiple Parameters To Web Service

Oct 6, 2010

I have a simple Web Service method defined as:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string MyWebMethod(string foo, string bar)
{
// DataContractJsonSerializer to deserialize foo and bar to
// their respective FooClass and BarClass objects.
return "{"Message":"Everything is a-ok!"}";
}
I'll call it from the client via:
var myParams = { "foo":{"name":"Bob Smith", "age":50},"bar":{"color":"blue","size":"large","quantity":2} };
$.ajax({
type: 'POST',
url: 'https://mydomain.com/WebServices/TestSvc.asmx/MyWebMethod',
data: JSON.stringify(myParams),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response, status) {
alert('Yay!');
},
error: function (xhr, err) {
alert('Boo-urns!');
}
});
However, this yields the following error (a breakpoint on the first line in MyWebMethod() is never hit):
{"Message":"No parameterless
constructor defined for type of
u0027System.Stringu0027.","StackTrace":"
at
System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary2
dictionary, Type type,
JavaScriptSerializer serializer,
Boolean throwOnError, Object&
convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object
o, Type type, JavaScriptSerializer
serializer, Boolean throwOnError,
Object& convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object
o, Type type, JavaScriptSerializer
serializer, Boolean throwOnError,
Object& convertedObject)
at
System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2
rawParams)
at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext
context, WebServiceMethodData
methodData, IDictionary`2
rawParams)
at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
context, WebServiceMethodData
methodData)","ExceptionType":"System.MissingMethodException"}

I'd like to pass in two string parameters and use DataContractJsonSerializer to write new Foo and Bar objects. Am I missing something?

View 3 Replies

WCF / ASMX :: Passing SessionID Using Web Service?

Jan 27, 2011

I'm running a WebMethod when a user clicks a link and I want the service method to have access to the clients SessionID but when I try to initialise a new string it returns a null value.

So to clarify(an example):

[WebMethod]
public string myMethod()
{
string s = Session.SessionID.ToString();
//rest of method here...
}

string s is returning null value. The code works fine on a postback and the method works without SessionID but I really want/need to be able to use a callback and need to be able to use the SessionID

View 4 Replies

C# - Passing Parameters In Windows Service?

Aug 18, 2010

I want to develop a windows service which will be accepting a datatable from an aspx page. Both the windows service and the website are hosted on same machine.

Also I need to set a date and time on which this service is to work. this date and time are to change according to customer needs. once again the date and time are to be fed from the aspx page.

View 6 Replies

WCF / ASMX :: Passing SoapHeader To Java Web Service

Feb 23, 2011

I have web service (.NET 2.0), in this i have added proxy class of my client's web service. Client's web service is in Java. I have to pass SOAP requet in following format

<soap:Envelope xmlns:soap="[URL]xmlns:xsd="[URL]xmlns:xsi="[URL]instance">
<soap:Header>
<AuthenticationToken xmlns="[URL]
<Username xmlns="[URL]XXX</Username>
<Password xmlns="[URL]YYY</Password>
</AuthenticationToken>
</soap:Header>
<soap:Body>
</soap:Body></soap:Envelope>
for this i have written following code but it's giving error as "Request must include authentication token"
-- code start--
public class WebService : System.Web.Services.WebService {
public WebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
public MyHeader AuthenticationToken = new MyHeader();
public MyHeader MyHeader
{
get { return AuthenticationToken; }
set { AuthenticationToken = value; }
}
[WebMethod]
[SoapHeader("AuthenticationToken")]
public string HelloWorldTest1()
{
AuthenticationToken .Password = "username";
AuthenticationToken .Username = "password";
ClientWebServices s1 = new ClientWebServices();
string soapbody="";
string res=s1.addmethod(soapbody);
return res;
}// end of method
} //end of service class
public class MyHeader : SoapHeader
{
public string Username;
public string Password;
}
-- code end--

View 1 Replies

Security :: Passing Certificate To External Web Service?

Apr 14, 2010

I'm calling an external Web service that requires a certificate to be passed. This works perfectly fine for a stand-alone Windows Forms application, but when I attempt to do the exact same thing through an ASP.NET Web Application, it throws the following error:

"No connection could be made because the target machine actively refused it"

I found this MS article that describes what appears to be the exact issue I'm having, but it only applies to .NET 1.0:

[URL]

I'm using .NET 3.5, so surely it must be fixed by now!

I've attempted to change permissions on the certificate and fooled around with the app pool identity, but nothing seems to work.

View 2 Replies

Using .net Mvc 2 And WCF - Passing Generic Object To The Service Call?

Mar 11, 2011

[DataContract]
public class UserCertification
{
...
}
[DataContract]
public class UserPhone
{
...
}
[code]...

View 2 Replies

State Management :: Passing Session In Web Service?

Mar 26, 2011

I have a number saved in session and am using it in a bunch of pages right now, and I was wondering if I could somehow access this session in my WebService.asmx file? It would be great since then that way I can fix my auto complete extender. I know I can use contextKey, but I am using that contextKey for something else. If session isn't possible in web service, then is it possible to use two contextkeys in auto complete extender, and how?

View 1 Replies

Passing A Web Service An Unknown Number Of Parameters?

Apr 28, 2010

I'm relatively new to utilizing web services. I'm trying to create one that will be accepting data from a ASP.Net form whose input controls are created dynamically at runtime and I don't how many control values will be getting passed. I'm thinking I'll be using jQuery's serialize() on the form to get the data, but what do I have the web service accept for a parameter? I thought maybe I could use serializeArray(), but still I don't know what type of variable to accept for the JavaScript array.

Finally, I was thinking that I might need to create a simple data transfer object with the data before sending it along to the web service. I just didn't wanna go through with the DTO route if there was a much simpler way or an established best practice that I should follow. Thanks in advance for any direction you can provide and let me know I wasn't clear enough,

View 3 Replies

Passing ID Of Element To A C# Web Service (using JSON) From JQuery?

Mar 9, 2010

I have an containing a list of divs that jQuery turns into progress bars. On .ready, I build a list of all of these progress bars and for each one, call a webservice that gets a value indicating how full the progress bar should be. In order to do this, I need to pass the ID of the div to the web service.

Because the divs are inside a ListView, I manually set the id to be id="completionbar_<%# Eval("MilestoneID") %>"

However, when I pass this id into my web service, it comes up as "undefined" every time. When I view the source, it looks like it's set correctly.

Here's the jQuery that calls my web service:

<script type="text/javascript" language="javascript">
$(document).ready(function() {
$(".MilestoneCompletion").progressbar({ value: 0 });
$.each($(".MilestoneCompletion"), function(index, barDiv) {

[Code].....

I'm thinking maybe the script is executing before the DIV id is set by the ListView databind?

View 2 Replies

MVC :: Passing Values From Controller To Service Layer?

Mar 24, 2011

I am working on Tenant module that has to display following fileds, Tenant Id, Tenant Desc, Contact Person, Contact Phone. In the DB, these are designed as two separate tables - Tenant and Contact. Tenant table has Tenant Id, tenant Desc and Contact Id . Contact table has all the contact related properties. I am using EF as DAL.

To make my system loosely coupled, I have created a repository pattern to talk to EF entities. Also, for validation I am using service layer.

My repository layer has two interfaces and classes corresponding to Tenant and Contact.

public interface ITenantRepository : IRepository<Tenant> // IRepository<T> is a generic interface for CRUD operations
{
Tenant Get(int id);
IEnumerable<Tenanr> List() ;

[Code]....

View 4 Replies

JQuery AJAX Not Hitting Web Service When Passing Parameters?

Jul 28, 2010

js:

[code]....

I put a break point inside MyWebMethod. When I invoke this call on the page, the break point never gets hit. It works fine when I remove all parameters from MyWebMethod's signature and pass in '{}' from JS as parameters. Once I try to pass in a string parameter, it stops working.

View 1 Replies

Web Service - Passing A Base Object With List / Collection?

Apr 9, 2010

We need to create a simple web service in ASP.NET that can be called from PHP or other languages. This in turn will be used to update records in a database for an item submission.

The core part is fairly simple, we have a base set of fields for the object - first name, last name, birth date, city, etc. In addition however we need to accept a list of items associated with that object that can range from 0-n.

Jan 1 2009, ABC
May 1 2010, 123
Jun 30 2010, XXXXX

What would be the best way to structure this so it can be easily passed to the ASP.NET web service and processed as a single call for the entire object? Would passing the list of items as a single delimted string be a wise approach? Ex: Jan 1 2009, ABC|May 1 2010, 123|Jun 30 2010, XXXXX

View 1 Replies

Security :: Passing User Credentials To WCV Service Hosted In IIS?

Mar 3, 2010

I'm running an ASP page that is using a WCF client to get some data. How can I set/pass the Network Credentials (of the user that performed the request, not the .net pool thread) on the WCF client so the WCF service will be able to perform impersonation using these credentials ?

View 1 Replies

Passing Custom Object As Parameter To A Webmethod Of Web Service?

May 11, 2010

I have a custom class declared as follows (in vb.net)

<Serializable()> _ Public
Class NumInfo Public n As String
Public f As Integer Public fc As
char() Public t As Integer

[Code]....

What am I doing wrong? For the record I tried replacing char() with string to see if it was the array causing problems but that didn't help either. I'm fairly new to web services. I tried replacing the custom object parameter with a primitive parameter just to check how things worked and it rendered a page with an input field and invoke button.

View 1 Replies

WCF / ASMX :: Passing A Web Service To A Method In Class Library?

Mar 23, 2011

I have a web service called service1. Is it possible to pass the parameter related to the service to a class library so for e.g.

Service1.service ws = new Service1.service();
Service1.UserDetails ud = null;

now if I call a method that exists in a class and pass ud. Cam i do that because I am trying to do this and I am getting an error. Do i need to add a web

reference to this service in the class library My method call is like this

authenticateUser.Authenticate(ud, UserName);

and in the class libary I have

public void Authenticate( Service1.UserDetails ud , string UserName)
{
}

View 3 Replies

C# - Passing Array List Of Specfic Type To The Web Service

Mar 31, 2011

How to Pass array List of specfic Type To the Web Service?

View 1 Replies

AJAX :: Passing Return Value From A Web Service To A Label In A Form View?

Mar 17, 2010

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:

[Code]....

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:

[Code]....

View 10 Replies

Passing Folder Path String To Web Service Function Via JQuery.ajax?

Apr 24, 2010

I need to perform asp.net web-service function call via jQuery and pass asp.net application path to it. That's the way I'm trying to do it (code is located within asp.net page, e.g. aspx file):

[code]...

Function call works well, but applicationPath parameter doesn't passed correctly. When I debug it I see that backslashes are removed, function gets "C:ProjectsSamplesmytestwebsite" instead of "'C:ProjectsSamplesmytestwebsite'".

View 2 Replies

Sitecore Home Page "occurred During The Processing Of A Configuration File Required To Service This Request"

May 24, 2010

I have installed all on my server 2008. When i got to /localhost/sitecore/Website/sitecore. i get following error. what should i need to do Description: An error occurred during the processing of a configuration file required to service this request. review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. Source Error:

Line 2575: <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 2576: </httpHandlers>
Line 2577: <membership defaultProvider="sitecore"> -- this line shows errr
Line 2578: <providers>
Line 2579: <clear />

View 1 Replies

Jquery - JSON Can Call Method In .aspx File But Not In .asmx (web Service) File

Jul 3, 2010

I am using JQuery & JSON (POST) to call webmethod. However I can call only webmethod located at aspx file but not in asmx file Below are sample codes

CustomValidate.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Public Class CustomValidate
Inherits System.Web.Services.WebService
'ACCESS VIA JSON
<System.Web.Services.WebMethod()> _
Public Shared Function AJAX_Test(ByVal date1) As Boolean...
Return True
End Function
End Class
Javascript: JQuery JSON
function isDates(source, arguments) {
var isValidDate;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CustomValidate.asmx/AJAX_Test",
data: '{date1: "' + arguments.Value + '"}',
dataType: "json",
async: false,
success: function(result) {
isValidDate = result;
},
error: function(httpRequest, textStatus, errorThrown) {
alert("status=" + textStatus + ",error=" + errorThrown);
}
});
arguments.IsValid = isValidDate;
}

It always return javascript undefined error. But if I put the AJAX_Test webmethod in aspx page and replace the url: "CustomValidate.asmx/AJAX_Test" to "mypage.aspx/AJAX_Test". It works fine.

View 1 Replies

WCF / ASMX :: Web Service Reading *.txt File .this File Contains Some Special Characters Like "?

Jan 21, 2011

In web service reading *.txt file .this file contains some special characters like "" .so its shows error while reading .

string fullPath = Server.MapPath("sample.txt");
string reconciliationData = string.Empty;
StreamReader ObjReconciliationDataStream = new StreamReader(fullPath, Encoding.UTF8);
string strReconData = ObjReconciliationDataStream.ReadToEnd();
ObjReconciliationDataStream.Close();
ObjReconciliationDataStream = null;
return strReconData;

above code i am using .

View 2 Replies

WCF / ASMX :: Want To Delete The File Using The Same Web Service Where Stored That File In The Another Database?

Aug 9, 2010

I m accessing another application by consuming webservice of that application. I m sending file to store and retrieving file from other dabatase. Web service is the only to access another application.Now, I want to delete the file using the same web service where I stored that file in the another database.I m getting exception and I m unable to figure it out.

View 2 Replies

MVC :: File Not Passing To Controller?

Aug 23, 2010

I am getting an null referance on file, what am I doing wrong.

<% Html.EnableClientValidation(); %>
<% Html.BeginForm("AddMedia", "Pattern", new { id= Model.Pattern_Guid} , FormMethod.Post, new {enctype = "multipart/form-data"}); %>
<%: Html.ValidationSummary(true) %>
<%: Html.Label("height") %>
<%: Html.TextBox("height") %>
<%: Html.Label("width") %>
<%: Html.TextBox("width") %>
<%: Html.Label("Media") %>
<input type="file" id="Media" name="Media" />
<input type="submit" name="btnAdd" value="Add" />
<% Html.EndForm(); %>

controller code:

[HttpPost]
public ActionResult AddMedia(Guid id, HttpPostedFileBase file, FormCollection collection)
{
string mimeType = file.ContentType; // Null Exception here ....

View 2 Replies

Passing Value To Another Page Using Https / Cannot Read The Control Values From Default.aspx Page

May 30, 2010

I need to force SSL when going to the final checkout page (for example from default.aspx to checkout.aspx).

I need to pass variables to this check out page and tried to use server.transfer(https://www.mydomain.com/checkout.aspx). I then use previous page .Fincontrol to read text box and label name to this check out page. If I only do the server.transfer("~/checkout.aspx") then my I can read all vakues of my controls from the passing default.aspx page.

But when I force https:// then I cannot read the control values from default.aspx page.

Please give me some tips on how to get control values to the https:// destination page or if you have another tips on how to do it the right way, please let me know.

View 8 Replies







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