WCF / ASMX :: Upload Xml File To Wcf Service And Validate That Data
Jan 19, 2011I am new to wcf . I want to implent one wcf service like upload xml file from cient to wcf service .
View 2 RepliesI am new to wcf . I want to implent one wcf service like upload xml file from cient to wcf service .
View 2 Replieshow to write a function in a web service to upload a file, like a .csv, to SQL Server.
The idea would be to upload the file via an interface built in Flex, send it to the server, and insert the record in SQL Server. My problem is that I don't know how the function should look like:
[Code]....
Should it ask for a String?
I have a very simple WCF Web Service it has methods like the ones below. It should be said that my webservice is very simple, I didn't do any configuration. Now I want to upload and download photos like .jpg or .jpeg files. But my question to you how shall I write the methods to be able to download and upload photo files to the WCF web service from my client?
[Code]....
I have a .net app developed in .net 4.0 version. And I implemented an asmx web service in this. Now I want to call one of the webservice method in another classis ASP application java script function.
View 2 RepliesI want to Upload bulk images from client to server using web service...
I already create web service for uploading images but it does not support well.. i have used byte array for that..
i use these code to set limit size for image that users want to upload
protected void BtnUploadS_Click(object sender, EventArgs e)
{
string path = Server.MapPath(".") + "../image/House";
[Code]....
here i define if (fup1.PostedFile.ContentLength < 102400) this size for image but when i upload image that has more than this 100KB it show error ===File size of 756 KB is exceeding the uploading limit but it upload file i don't want users can upload file morethan 100KB but here show error but upload image why?
I do not want to change the default settings for file upload, 4Mb is more than enough for the project I'm working on. After quite a bit of searching I found two approaches that were purported to work but neither one is preventing the "Maximum request length exceeded" error. The first approach[see ref. #1 below] performs validation with a custom validator and in code behind on the page that contains the FileUpload control. It doesn't work. The second approach [see ref #2 below] performs validation in the Application_BeginRequest event in Global.asax. The author stated that validation must be handled by this event. Quoting: "The way to get past is to use your Application_BeginRequest event to handle the problem.. This event takes place for each request to your application BEFORE the data has been completely uploaded. Here you can check for the content length of the request and then redirect to the some error page or the same page with some value in session or query string so that the page can show appropriate message to the user." Here is my code from Golbal.asax based on the above. As noted, this approach doesn't work either.
protected void Application_BeginRequest(object sender, EventArgs e)
{
const int maxFileSize = 4 * 1000000; // Slightly less than 4Mb
if (Request.ContentLength > maxFileSize)
{
Response.Redirect("~/FileUploadError.aspx");
}
}
One comment by a reader of the Global.asax approach was that the value returned by Request.Content.Length would include everything on the page, i.e. viewstate, image and text content, etc. I suppose one work-around would be to set the limit higher in web.config but validate for max. file size in code behind, but that seems kind of silly because I'm manipulating the uploaded files (images) to reduce the size anyway; storage space isn't the issue, performance is. Has anyone managed to solve this poblem?
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.
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 .
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 RepliesI am trying to upload file in WCF.When I try to upload file I am getting following error message. System.ServiceModel.CommunicationException:The socket connection was aborted.
View 4 RepliesI'm trying to upload a file to an ASP 2.0 web service through HTTP 1.1 POST from a client-side application. If my web service function is declared as
<WebMethod()>
Public Function UploadFile(ByVal file as Byte(), ByVal fileName as String) as String
...
The test form says the request should take this form:
POST address_of_service HTTP/1.1
Host: <host>
Content-Type: application/x-www-form-urlencoded
Content-Length: length
file=string&file=string&fileName=string
How do I get my binary file data into that form? I've tried just converting the file data to a string and putting it in the body (file=<string_data_here>) but I get HTTP 500 errors back, complaining about not being able to convert it to System.Byte. I've got HTTP POST working fine elsewhere in my application with plain string parameters. Also, out of curiosity, why is it showing the file parameter twice?
I am using ASP.NET 2.0 and trying to use a simple Form to upload a file to a web service. I have the action attrib set to the url of my web service. However, in firefox, I can't see that it is making any call to that service at all. NOTE: I can throw int the below "Action" value to a browser minus the name of the web method and get a page showing the available web method so I believe the URL for the "Action" attribute is correct.
<form id="fileUpload" action="http://localhost/AcmeABC/services/FileUploadService.asmx/ImportRates" method="post" enctype="multipart/form-data">
<input type="text" id="fileName" name="fileName" />
<asp:FileUpload runat="server" id="fileArray"/>
<input type="submit" value="Submit" />
[WebService(Namespace = [URL]/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[ScriptService]
public class FileUploadService : System.Web.Services.WebService {
[WebMethod]
public void ImportRates(string fileName, byte[] fileArray) {
try {
MemoryStream memoryStream = new MemoryStream(fileArray);
}
catch (Exception ex) {
string error = string.Format("Error thrown for file {0} with {1} error.", fileName, ex);
}
}
How can I see what is going on since I don't see any call be made. I am also of the opinion that this might not be the best approach. I am new to the entire web development space so I am trying to find better ways of handling problems.
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 RepliesI wrote a small web service (asmx) to write stuff to a file on the server. It works fine when run in the VS2008 test container. But when I run it under IIS on a remote machine, I get:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'y:grahammiscprops.txt'.
'y' is a mounted drive on both the test and remote machines. The path really does exist. It works on the test machine; not remotely. So:
Is it the fact that 'y' is a mounted drive causing it to fail remotely? or Is it the fact the the path lies outside of the web application directory structure? Is there something I should put in web.config??; or
Is something else the problem? I would have thought that the service running on the server could do anything it wanted! It's not denying me access to the file; it's saying it can't find it??!!
I have a large web application that uses File.Exists() in a global file utility class flawlessy for several years now. I just built a new ASMX web service that calls that same method in our file utility class, and it returns False for the same exact file paths that are being passed in the web application. The paths are absolute system file paths, and they match on both the web service and the web app.I am confused... Why might this happen? The method I am talking about is only a few lines of code. A couple of lines simply validate the file id parameter being sent into the method. The last remaining line is this:
[Code]....
The previous line of code calls another method that uses a String.Format to insert the file id into the file path. That's it.
I've been trying to get my Web Service in my wcf project to be able to reference the resource objects in my resource file but to no avali.Please kindly advice and assist on what went wrong.
View 1 RepliesI upload the file. I m creating web service to read that uploaded file. how can I access that uploaded file path in web service.? How can I read the uploaded file using web service?
View 5 RepliesHow to write self hosting for wcf service with multiple svc file ServiceHost myServiceHost = null;
View 1 RepliesI am downloading the project from the webservice which contains the zip file embedded in the Soap XML.
I want to read or download the content present in the Zip file.
I am using C#.
I am trying to create a web service that can check a location for file and if available get the contents.
Also this web service has to upload the file using ftp after making changes locally.
Any pointers in this direction.
I would like to read the WSDL file from KEGG [URL] in order to use the
[Code]....
I need to store a pdf file on client machine using a web service.
I am unable to find IP address of client machine in web service so that I can insert pdf file in C-drive of client machine.
I am using asp.net 3.5 using c#.
I am adding a reference of class library in web service in VS2008 and it is not copying the .config file from class library to web service. I have checked the property "Copy to output directory" of .config file and its value is "Copy Always".
View 3 RepliesI've been reading quite a few tutorials on web services and xml files and one thing isn't quite clear to me. If I want to create an XML file on the fly the tutorials are pretty straight forward but, I want to grab an existing XML file from the web server and return the whole thing. Do I need to read the XML file and send each individual node or is there a way to send the file all at once? The tutorials imply that the whole file could be a node but I'm not clear on what that entails or if it would work. Also do you have a link to an example?
View 1 Replies