C# - Calling WebService From Same Project?
Apr 19, 2010
I'm trying to call an asp.net webservice from the same project it's in:
[MethodImpl(MethodImplOptions.Synchronized)]
public static void OnFileCreated(object source, FileSystemEventArgs e) {
trackdata_analyse rWebAnalyse = new trackdata_analyse();
rWebAnalyse.Analyse(@"pending" + e.Name, "YOUNIVATE");
}
However i always get the following "HttpContext is not available. This class can only be used in the context of an ASP.NET request." when calling Server.MapPath from the webservice:
[WebMethod]
public int Analyse(string fileName, string PARSING_MODULE){
int nRecords;
TrackSession rTrackSession = new TrackSession() ;
string filePath = Server.MapPath(@"..data") + fileName;
Do i have to add the WebReference instead, though the webservice is in the same project?
View 3 Replies
Similar Messages:
May 10, 2010
i have an project with name called(dbservice layer) which is in path: d:webserviceDBService. here i have an webservice which connects to DB and returns an object of an class.
once i added an reference here i get an url:http://localhost:2371/Jobs.svc
now i have another project name (UILayer) whic is in path: E:SchoolUILayer i added an service reference here with url as http://localhost:2371/Jobs.svc but i get an messgae telling service is unable why is that happening.
if both my webserivce layer and ui layer are in same project. then i able to use the webserive in the ui layer. and get the required output
so i wanted to know is there any way we can acesss the webserive from one project to another project
View 1 Replies
Oct 27, 2010
I have almost the same problem as you have described in [URL] service. I have a asp.net webservice that calls a WCF service. On my development machine this is working fine. But if i deploy my ASP.net Webservice it is not working. Both the ASP Webservice en WCF service needs my cridentials. How did you solved your problem. In the logging of the WCF service I see that my credentials is not passing to WCF.
View 1 Replies
Feb 6, 2011
I am new to programming especially jQuery and webservices. I want to pass the values to the to database via the webservice. Below is the code for the .aspx page:
<html xmlns="[URL]xhtml">
<head id="Head1" runat="server">
<title></title>
<link href="[URL]"
rel="stylesheet" type="text/css" />
<script src="[URL]" type="text/javascript"></script>
<script src="[URL]"
type="text/javascript"></script>
<script src="[URL]"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#sortable").sortable();
$("#sortable").disableSelection();
$("#sortable input[type=text]").width($("#sortable img").width() - 10);
$("#sortable label").mouseover(function () {
$(this).parent().children("input[type=text]").show().val($(this).html());
$(this).hide();
});
$("#sortable input[type=text]").mouseout(function () {
$(this).parent().children("label").show().html($(this).val());
$(this).hide();
});
$(".ContainerDiv").hover(
function () {
$(this).find(".deleteClass").show();
},
function () {
$(this).find(".deleteClass").hide();
});
$(".deleteClass").click(function () {
$(this).closest("li").remove();
});
$("#orderPhoto").click(function () {
var photos = $.map($("li.ui-state-default"), function (item, index) {
var imgDetail = new Object();
imgDetail.Id = $(item).find("img").attr("id");
imgDetail.Caption = $(item).find("label").html();
imgDetail.Order = index + 1;
return imgDetail;
});
//photos contains all the photo and order and the chhanged caption.
//pass to server
$.ajax({
type: "POST",
url: "WebService.asmx/updateOrder",
data: JSON.stringify(photos),
contentType: "application/json; charset=utf-8",
success: function (data) {
if (data.d === "saved") {
$("<p>").text("New order saved!")
.addClass("success").appendTo("#left");
} else {
$("<p>").text("Save failed")
.addClass("failure").appendTo("#left");
}
}
});
});
});
</script>
<style type="text/css">
#sortable
{
list-style-type: none;
margin: 0;
padding: 0;
}
#sortable li
{
position: relative;
margin: 3px 3px 3px 0;
padding: 1px;
float: left;
text-align: left;
}
.deleteClass
{
/* PhotoListItem is relative so relative to it */
position: absolute;
top: 1px;
right: 3px;
background: black;
color: Red;
font-weight: bold;
font-size: 12px;
padding: 5px;
opacity: 0.60;
filter: alpha(opacity="60");
margin-top: 3px;
display: none;
cursor: pointer;
}
.deleteClass:hover
{
opacity: 0.90;
filter: alpha(opacity="90");
}
.image_resize {
width: 250px;
height: 250px;
border: 0;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ListView ID="ListView1" runat="server" GroupItemCount="15">
<LayoutTemplate>
<ul id="sortable">
<li id="groupPlaceholder" runat="server">1</li>
</ul>
</LayoutTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<ItemTemplate>
<li class="ui-state-default">
<div class="ContainerDiv">
<div class="deleteClass">X</div>
<img id='<%#Eval("photo_id")%>' src='<%# "uploads/"+Eval("photo_file_name")%>' alt="" class="image_resize" />
<div style="height: 25px; margin-top: 3px">
<label>
<%# Eval("photo_title")%></label>
<input type="text" style="display: none" />
</div>
</div>
</li>
</ItemTemplate>
</asp:ListView>
<input type="button" id="orderPhoto" value="Save change" />
</form>
</body>
</html>
I used the debugging tool and can confirm that the photos contains the correct values. Its just calling the webservice part that I am unsure about.
View 1 Replies
May 13, 2010
I need to call this webservice from a ssis package.In the ssis package i should be mentioning the wsdl path of the webservice. How can wsdl path of a webservice be obtained?
View 4 Replies
Dec 9, 2010
I need to call a Java webservice from my ASP.Net application. The webservice uses Java Key Store (JKS) certificate. Could some one help me with how I could do this? As a side note, when I try to add Web Reference or Service Reference to my Visual Studio project by providing the WSDL, Visual Studio always crashes.
View 1 Replies
Oct 2, 2010
We have an ASP.NET website which calls a webservice. If impersonation is not on for the ASP.NET website the call to the webservice is slow - using WireShark we see that it is making WPAD queries. If impersonation is on and it's impersonating an admin user the call to the webservice is fast - using WireShark we that it is NOT making WPAD queries. Has anyone seen this before? How do we prevent the networkService, which by default is what the ASP.NET website uses, does not make WPAD queries. Why does impersonating as an admin user not cause WPAD queries?
This is the entry we see in WireShark:
NBNS Name Query NB WPAD<00>
View 1 Replies
Jun 21, 2010
Here is aspx code. that refers Master Page.
<
asp:TextBox
ID="txtClientSearch"
CssClass="txtfld01"
Width="75%"
runat="server"></asp:TextBox
[Code]....
Now i dont understand why my Autoextender is not call the webservice. I have tried callin the webservice from button click event...it works but not using AutoExtender..
View 2 Replies
Feb 11, 2011
I have an old legacy webservice that I need to call from a controller ActionResult and I have no idea how to do it.
View 5 Replies
Feb 15, 2012
I have an intranet application that is calling a webservice (code below). The webservice calls a stored procedure in q sql server 2005 that again does an openquery on a db2 (AS400) machine. The stored procedure is returning a temp table. On the call to the webservice I am getting a time out. At this point if time out the web service is still running and I can also see the query is in the program stack on the db2 machine. The query itself can take up to 20-30 minutes as it is reading 3 mill+ records. If I call the web service directly I get the result returned.
Code:
Dim getOrderDetail As New localhost.OrderDetail
myDataTable = getOrderDetail.GetOrderDetailRecords_DataTable(myUserId)
View 5 Replies
Apr 6, 2010
I'm generating a file on the server which takes some time. For this, I have a hidden iframe which I then set the .src attribute to an aspx file i.e iframe.src = "/downloadFile.aspx"While this is taking place, I'd like to have a call to a web service return the progress. To do this, I thought I could use window.setInterval or window.setTimeout but Javascript seems to be blocked as soon as I set the iframe src attribute.Does anyone know how to get around this or perhaps try a different approach?I have also tried handlers, but the request never gets to the server so I'm assuming is a browser/javascript issue.
//Function that gets the file
function GetFile() {
setTimeout(GetProgress, 1000);
var iframe = document.createElement("iframe");
[code]...
View 2 Replies
Nov 17, 2010
This is the webservice am using.
[code]....
But my function is not going to Hello() soon after calling SetOCXVariables()
After my 'P' comes undefined and does the remaining, it goes to hello()
why is this happening?
View 7 Replies
Oct 5, 2010
I've tried a bunch of different examples and still can't get this to work. I have a jQuery GalleryView control I'm using and I simply want to log impressions. I set up a webservice that works, but I can't figure out how to get it to work in javascript. I have verified that the webservice is working as expected.
Imports System.Web
View 2 Replies
Dec 7, 2010
I've inherited a half completed application that seems to use a model that I'm not sure can reliably work.It is a ASP.NET webservice that on each call loads a unmanaged C++ .DLL using
[DllImport ( "kernel32.dll" , EntryPoint = "LoadLibraryA" )]
public static extern int LoadLibrary( string lpLibFileName );.
[DllImport(@"MyUnamanagedDLL.dll")]
public static extern string DoStuff( );
In the unmanaged C++ .dll it is using a singleton to hold state between calls.This is so that it only has to initialise once and load a bunch of slow stuff from disk and database rather than on each webservice call as this is too slow.
View 3 Replies
Dec 10, 2010
Well i dont have an error but would like to get some guidance on this. I have a webservice that calls a class. The Class translates numbers to figures i.e. 4000 will return a string 'Four Thousand Shillings'. So what i actually want is how i can do my processing
backwards so that in the service i call the class's method to return a string so that i put the results on a Text property of a Label Control while i type each figure in a TextBox Control.
i.e. if i type 4 in my text box, i should see 'Four in my label', then 40 will return 'Fourty Shillings', then 400 will return 'Four hundred'
View 3 Replies
Mar 23, 2011
I have a page that calls a webservice from JavaScript using the approach described in this article: [URL]
This is working fine. The problem is when the page causes a postback before the end of the execution of the webservice's method. When that happens, the succeeded callback method never gets called. Does anyone know if there's a workaround to this?
View 2 Replies
May 19, 2010
I am using Asp.Net application for calling an existing Java webservice. Recently the web service is configured with Security certificates. Now I need to call the webservice using "https:URL .." and by passing the credentials i.e. UserId and Password.
When I call the webservice using [URL] I get the below error. Is the change in my code is causing this error?
Error:Client found response content type of 'text/html; charset=iso-8859-1', but expected 'text/xml'. The request failed with the error message: --
500 Internal Server Error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. contact the server administrator, you@your.address and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
IBM_HTTP_Server Server at ............ Port 443
View 1 Replies
Mar 12, 2010
I need to create a simple webservice in C# but I'm not sure where to start (I've coded UI apps in C# before but all my web experience is in Ruby on Rails). Where do I start?
The only client for the webservice will be a Ruby on Rails app so there's no need for any HTML rendering. I was thinking of just returning a XML or YAML formatted string unless there's an easier way. I'm not too keen on SOAP but if it's easy/natural in C# & Ruby then I'd consider it (or anything else).
View 4 Replies
Apr 4, 2011
auto complete Extender not calling the webservice method the exact problem is ., Am using AutoComplet Extender in Example project its working fine. but the same code(aspx code as well as webservice code) am using in my live project its not calling the web service method. my live project is dotnet 2.0 version
[Code].....
View 1 Replies
Jul 19, 2010
I am using the Login Control and the Login.aspx page for Login authentication. How can I call login from another page or a webservice method with a Userid and password parameters.
[Code]....
View 3 Replies
May 29, 2010
I just wana know that can I bind an asp listview via javascripts by calling a webservice in c#??
View 2 Replies
Apr 20, 2010
I get this error "The server method xxx timed out." calling a WebService that internally does a hard query to the database, and takes some time. I use this method to change the webservice timeout, but it does not seems to do anything (the timeout errors appears in less than a second).
MyService.set_timeout(100000);
View 2 Replies
Feb 26, 2010
I want to add items to a dropdownlist with values return by a webservice which will be called from javascript without cascading extender...
View 3 Replies
Jul 12, 2010
In IIS I have a virtual directory with only windows authentication enabled. From Javascript I call into a ASMX webservice. From the ASMX webservice I make a call to the SharePoint Search.asmx Webservice. whatever I try I keep getting the followin gerror message:
"The request failed with HTTP status 401: Unauthorized"
I use the following code to call the SharePoint webservice
[Code]....
My web.config settings are:
[Code]....
The Sharepoint farm is configured to use NTLM authentication.
Strangely everything works when I am testing in Visual Studio using the builtin webservice, but when I deply to my local IIS or Test Server it breaks.
View 1 Replies
May 25, 2010
I ultimately need to show countries in one drop down then states/provinces drop down of the previously selected drop down. I'm sure everyone has seen this many times. My page shows the countries but does not show values in the province/states drop down. It's as if the webservice is never run. I've tried removing and adding the ajaxtoolkit reference. The tableadaters run simple working sql code. I'm really at a lose here.
default.aspx:
...
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
...
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<%--Dropdown to display countries--%>
Country:<asp:DropDownList ID="ddlCountries" runat="server" DataSourceID="ods_Countries"
DataTextField="country" DataValueField="abbreviation">
</asp:DropDownList>
<%--data source for the country drop down list--%>
<asp:ObjectDataSource ID="ods_Countries" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllCountries" TypeName="countryDataSetTableAdapters.CountriesTableAdapter">
</asp:ObjectDataSource>....................................
View 8 Replies