Search code examples
batch-filewsdlasmxcommand-prompt

.bat Error: 'http:' is not recognized as an internal or external command, operable program or batch file


I've come across another dead end in trying to SET UP, let alone run, a Unit Test from an existing ASP Web Site using Visual Studio 2012/2013, but I thought this question merited a question of it's own since, although I've seen similar questions asked, everything I've tried for the past 5 hours has yielded something between 0 and Null (not literally, that would be helpful if I would get such output),

The contents of my batch file were, following the instructions of sitepoint.com's Creating and Consuming .NET Web Services in 5 Easy Steps:

wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs
http://localhost/webserv.asmx?wsdl

Since I'm trying to follow the steps of an article that's over a decade old, syntax and conventions may easily have changed. But hey, it was able to guide me through making a working .asmx page, so I've tried to stick with it. Anyways, when I run makeWS.bat on the Developer Command Prompt for VS2012, I get the error:

'http:' is not recognized as an internal or external command, operable program, or batch file.

In attempting to fix the problem, my makeWS.bat page currently looks like:

wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs
http://localhost:20141/webserv.asmx?wsdl

Also, the .asmx file looks like this:

<%@ WebService Language="C#" Class="GetInfo" %> 

using System; 
using System.Data; 
using System.Data.SqlClient;
using System.Web.Services; 

[WebService(Description="My Suppliers List Web Service")] 

public class GetInfo : WebService  
{
  [WebMethod(Description="My WebService",BufferResponse=true)] 

  public DataSet ShowSuppliers (string str)  
  { 

    SqlConnection dbConnection = new SqlConnection("server=(local);uid=sa;pwd=;database=Northwind;");  

    SqlDataAdapter objCommand = new SqlDataAdapter("select ContactName, CompanyName, City, Phone from Suppliers  where Country = '" + str + "' order by ContactName asc", dbConnection); 

    DataSet DS = new DataSet();
    objCommand.Fill(DS);
    return DS;
    dbConnection.Close();
    dbConnection = null; 

  } 
}

When I run the ASMX page in Firefox from File Explorer, I got the error:

XML Parsing Error: not well-formed

However, running the .asmx page from VS2013 got everything to work smoothly. I thought maybe the localhost port might have played a factor, so I tried adjusting my batch file:

wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs
http://localhost:20141/webserv.asmx?wsdl

I tried turning Autorun off, I've added the http addresses as System Variables, but nothing has worked. Is anyone out there able to identify my issues because I was honestly incredulous when my Developer Command Prompt for VS2012 said it didn't recognize http:. Isn't Hyper Text Transfer Protocol integrated at the architectural level by now?

UPDATE

'http:' is not recognized as an internal or external command, operable program, or batch file.

is because the url is on a different line than the wsdl(.exe) command (whose argument it should be), and the batch consists (this is a simplified view) of a series of commands each on a different line. In order to get over this, merge the 2 lines into 1:

wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs http://localhost:20141/webserv.asmx?wsdl

or escape the eoln (\r\n) char by ^(caret):

wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs ^
http://localhost:20141/webserv.asmx?wsdl

and if everything is OK, you should have your bin/wsdlWalkthrough.cs file generated.

CristiFati's instructions got me past the initial hurdle. Now the new error is:

Error: There was an error processing 'http: //localhost/webserv.asmx?wsdl'. -There was an error downloading 'http: //localhost/webserv.asmx?wsdl'. -The request failed with HTTP status 404: Not Found.

This seems like something I could probably find the answer to myself, but further help would still be very much appreciated.


Solution

  • 'http:' is not recognized as an internal or external command, operable program, or batch file.

    is because the url is on a different line than the wsdl(.exe) command (whose argument it should be), and the batch consists (this is a simplified view) of a series of commands each on a different line. In order to get over this, merge the 2 lines into 1:

    wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs http://localhost:20141/webserv.asmx?wsdl
    

    or escape the eoln (\r\n) char by ^(caret):

    wsdl /l:CS /n:WService /out:bin/wsdlWalkthrough.cs ^
    http://localhost:20141/webserv.asmx?wsdl
    

    and if everything is OK, you should have your bin/wsdlWalkthrough.cs file generated.