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


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

(400) Bad Request when calling asmx webmethod dynamically

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ADO.Net
 

I am getting (400) bad request when I try to get response from the asmx webservice. Till now, I am able to run the service url provided by the user and get all the webmethods in a dropdown. I then create a SOAP message for the selected webmethod. When user clicks Execute button, I am trying to call the webmethod with SOAP message. Here is the c# code:

protected void btnExecute_Click(object sender, EventArgs e)
{
  HttpWebRequest req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(txtWSDL.Text));
  req.ContentType = "text/xml; charset=utf-8";
  req.Method = "POST";
  req.Accept = "text/xml";
  req.Headers.Add("SOAPAction", "http://tempuri.org/" + ddlMethods.SelectedItem.Text);
  StreamWriter stm = new StreamWriter(req.GetRequestStream(), Encoding.UTF8);
  stm.Write(txtFormattedSoap.Text);
  stm.Flush();
  stm.Close();

  WebResponse 


View Complete Post


More Related Resource Links

VS2005 calling VS2010 asmx service returns empty string

  

Anyone have any experience with this?

We are using VS 2005 for the front end, and vs 2010 for the web services part (asmx), not wcf yet.

 

Web service works just like the vs2005 when run locally, no problems.

 

Connecting to it from a test app returns an empty string. Connecting to a 2005 app doesn't!

Anyone run into this before or have a suggestion? Surely vs 2005 can connect to web services from a later version?

 

Thanks

 

Johan

 


While calling Web service gets exception "The request failed with HTTP status 401: Unauthorized"

  
Hi All, I created a ASP.NET web service, which was hosted on default visual studioserver, and on excecution of webservice it run .exe file which in turn update xml file. Now i hosted this webservice on IIS 6.0 server, and when i run the service, itfails to execute the exe.When i run it on debug mode, i never get any exception.Code...public string HelloWorld()    {        Process myProcess = new Process();        try        {            myProcess.StartInfo.UseShellExecute = false;            // You can start any process,             myProcess.StartInfo.FileName = @"E:\Projects\some.exe";            myProcess.StartInfo.CreateNoWindow = true;            myProcess.Start();            myProcess.Close();            myProcess.Dispose();            return "Suceess";         }&n

AJAX AutoCompleteExtender Not Calling WebMethod

  
I have the correct signature for the web method, and it works fine,  but for some reason it is not being called at all by AutoCompleteExtender<div> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> <Services><asp:ServiceReference Path="~/AutoComplete.asmx" /></Services> </asp:ToolkitScriptManager> <asp:TextBox ID="txtUser" runat="server"></asp:TextBox> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtUser" ServicePath="~/AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="1" EnableCaching="true" UseContextKey="false"> </asp:AutoCompleteExtender> </div>  Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Web.Script.Services Imports System.ComponentModel Imports System.Data.SqlClient ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiP

ASMX to WCF Soap request

  
I have a .asmx service that I need to convert to WCF. The service receives xml requests via the request input stream,  parses xml and sends clients back a response also in xml. The clients are sending SOAP requests. I have to make this change transparent to the clients. I'm somewhat new to WCF so i'm wondering what would be the best solution. REST looks good but I need to support SOAP. Is it possible to use basicHTTPBinding for my needs?

Intermittent timeout calling ASMX web service yet Upload data transfer completes OK

  
I'm calling my webservice from a web page and getting a timeout despite setting very high values in my web.config files. This occurs intermittently when the file is usually pretty large but yet the file is still getting uploaded completely (as if the timeout DID NOT occur). Here is a function in my .aspx file which calls my ASMX proxy class:
private void UploadFile(HttpPostedFile postedFile, string fileNameOnly) 
{ 
    // create an instance of the proxy class to talk to our service; calling it client: 
    string

Request format is unrecognized for URL unexpectedly ending in '/Webmethod name'.

  

We recently migrated our applications to .net 4.0/VS 2010/IIS 7.5. One of our application makes lot of AJAX calls to .asmx services using JQuery Ajax call. This was working great when on .net 3.5/IIS 6.0. But with the migration we continously are getting the error

 Request format is unrecognized for URL unexpectedly ending in '/Webmethod name'.

here is the exception information.

Exception information:

    Exception type: InvalidOperationException

    Exception message: Request format is unrecognized for URL unexpectedly ending in '/webmethodname'.

   at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)

Request format is unrecognized for URL unexpectedly ending in '/Webmethod name'.

  

We recently migrated our applications to .net 4.0/VS 2010/IIS 7.5. One of our application makes lot of AJAX calls to .asmx services using JQuery Ajax call. This was working great when on .net 3.5/IIS 6.0. But with the migration we continously are getting the error

 Request format is unrecognized for URL unexpectedly ending in '/Webmethod name'.

here is the exception information.

Exception information:

    Exception type: InvalidOperationException

    Exception message: Request format is unrecognized for URL unexpectedly ending in '/webmethodname'.

   at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)

IIS memory increasing for each client request in asmx web service

  

A customer reported that our asmx web service is continually increasing in memory (mem usage as well as private bytes).  We are able to reproduce the problem in our lab with Windows 2003 Server SP2 (fully patched) on some of the machines.  The customer is using Windows 2008.

We created a Hello World web service targeting the 2.0 framework built under VS2005 SP1 and a test client that continues to call it.  The memory increases steadily - approximately 40K per client request.  If the test app is paused, the memory remains the same.  When it is closed, the memory drops.  Explicit calling of GC.Collect does not drop the memory.

We have run the memory profiler on the service and the leak is all native memory.  We have uninstalled/re-installed the Framework on one of the machines but no difference.  To our knowledge all of the security and IIS settings are not modified.  We have compared app pool, default web site and virtual directory properties to  machines that have no problem and they are identical.

 
Has anyone else experienced this?  Any suggestions?


Convert WSDL file to asmx service WebMethod

  

Hi All,

Convert WSDL file to asmx

I have got wsdl file and based on wsdl  I am trying to create asmx service.

Wsdl file holding some credential user id and password it is working fine when I used SOAP UI tools

In same manner  when I am creating web method  like bellow given scarch code


[SoapHeader("authentication")]

    [WebMethod]

     public string getHierarchy()

    {

        string strResult="Hello", strRegion="";


       Service serviceProxy = new Service();


        UsernameToken userToken = new UsernameToken("admin", "password", PasswordOption.SendHashed);

        //SoapContext requestContext = serviceProxy.RequestSoapContext;

        serviceProxy.RequestSoapContext.Security.Tokens.Add(userToken);

        smartForms objSmartForms = new smartForms();//Object of WSDL

       strResult = objSmartForms.getHierarchy("TLANTIC",out strRegion);//invoking Method

How to pass the servicename and namespace dynamically for dynamic webreference - asmx

  

We have number of asmx services. I want to give an user a page with a textbox to input service url like http://abc.win.com/myservice/customerdata.asmx. When user hit "Load" button, dynamically I add all the web methods to the dropdown.

I was able to find a way to generate the proxy and the list of all the methods using this helpful link: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/39138d08-aa08-4c0c-9a58-0eb81a672f54

But, I found that I have to know the serviceName and the namespace beforehand to make this work. In real scenario, user will just enter any asmx, how will I know the namespace and the service name of the selected service upfront? Can I extract that too dynamically so that I don't need to change the code or build a list of all the namespaces and servicenames?


"The request was aborted: Could not create SSL/TLS secure channel." when calling third party web ser

  

I have a webservice that calls a third party web service over https. It used to work properly but now it's giving me problems in my dev and test environments. I don't want to attach the client certificate manually as the web service on production is running without any trouble. For the dev/testing I'm using the following code to work around the validation:

 

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);

...

public bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
    {
      return true;
    }

 

 

I also discovered that this might be because of an old microsoft security patch http://support.microsoft.com/kb/980436.

I have tested this service on machines with and without this patch and the result is the same error.

{System.Net.WebException: The request was aborted: Could not create SSL/TLS secu

Dynamically Create Controls in ASP.NET by Using Visual C# .NET

  
This article demonstrates how to dynamically create a control for an .aspx page. The sample project does the following:
Creates two TextBox controls.
Verifies that the contents (TextBox.text) and the attributes of the TextBox are saved across posts to the server.
Illustrates handling events that are posted by a dynamically-created control

Dynamically Create Controls in ASP.NET with Visual Basic .NET

  
This step-by-step article describes how to dynamically create controls for an ASPX Web page.

The sample project does the following:
It creates two TextBox controls.
It verifies that the TextBox contents (TextBox.text) and attributes are saved across posts to the server.
It describes how events that are posted by a dynamically created control are handled.

FORMAL REQUEST TO THE MICROSOFT DYNAMIC DATA TEAM

  

Dear gentlemen and ladies of the Microsoft Dynamic Data Team,

Mr. Steve Naughton says (and I hope so) that there might be chances that you read the posts published in this forum: I really hope so.

If that were the case then I am formally requesting to you in providing a "real answer" to my question:

I want to customize a dynamic data page (the details one) so I can have access to the data it has been already gathered from the end user UI (details.aspx) and use it to pass this same data to the following controls/pages that I am going to display next time to the end user.

For instance:

I have a screen with different types of data in it: texts, numbers, dates, check boxes, radio buttons and dropdownlists that has been filled with data by the end user. I want now to reset all fields exept the dropdownlist of which I'd like to keep the previously chosen values(the very same thing you do between dropdownlist of List.aspx ad Details.aspx). Even with FoxPro I could do that because data and controls were available there. It was as simple as setting carrying on to true.

HOW DO YOU DO THAT? HOW CAN I IMPLEMENT THE SAME LOGIC AMONG THE CONTROLS OF MY DETAILS PAGE? BUT I DO WANT TO HAVE ACCESS AND PASS DATA FOR SPECIFIC CONTROLS:DROPDOWNLISTS (mostly).

I have found my

dynamically adding sql server columns based on number of files in fileuploader

  

I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.

 

I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!

 

Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")

objConn.Open()

view state vs request parameters

  

If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


Thanks.



Unique ID throughout entire request

  

Greetings,

I am hoping somene here could advise me on a better solution to my present problem.  First a little background information on the application. 

I have a web application using the 3.5 framework.  The structure of this application is as follows: UI -> WebService   -> Business Layer -> DataAccess Layer.   What I want to accomplish is for every request (click on a link or button) have a unique identifer that follows this request through its entire lifecycle.  This unique identifer can be accessible anywhere within this request.  We use Response.Redirects which could easily be changed to Server.Transfers (although I do not want to do that) but  the problem lies with the web service calls.  Currently, a GUID is set in the ApplicationRequest.  This GUID checks for a guid value in the RawURL and if so, assigns this value to a HttpContext Item.  If not, HttpContext.Items gets a new one created.  However, this idea is wrong and will need to be revisisted.  The bigger problem is with the web service calls.  Without changing every web service method signature, and every call for that matter, is there a way of getting this GUID there.  I created a web method in every web service so that each time I instantiate a web service object in the UI, before calling any

Categories: 
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