Reputation: 2856
I have made a web service which is working well on my local machine.
On another machine it shows wsdl and description of methods when url is on remote machine
ipaddress is : 192.168.6.51
http:// ipaddress /GPCB/GPCBWebService.asmx
but when we enter url on remote machine
http:// ipaddress /GPCB/GPCBWebService.asmx/GetIndustryList
it throws runtime error on remote machine .but on local machine it runs well...
What can be the solution
The Code is as follows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Gpcb_ecModel;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;
using System.Web.Script.Services;
using System.Web.Mvc;
using Newtonsoft.Json;
using System.Web.Script.Serialization;
/// <summary>
/// Summary description for GPCBWebService
/// </summary>
[WebService(Namespace = "http://GPCB/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class GPCBWebService : System.Web.Services.WebService {
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Gpcb_ecConnectionString"].ConnectionString);
Gpcb_ecEntities gpcb1 = new Gpcb_ecEntities();
public GPCBWebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string About() {
return "GPCB";
}
[WebMethod(Description = "Get List of industries with all the fields")]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string GetFullIndustryList()
{
List<tbl_Industry_Registration> indlist = new List<tbl_Industry_Registration>();
indlist = gpcb1.tbl_Industry_Registration.ToList();
tbl_Industry_Registration[] indarray = new tbl_Industry_Registration[indlist.Count];
for (int i = 0; i < indlist.Count - 1; i++)
{
indarray[i] = new tbl_Industry_Registration
{
Category_Id=indlist[i].Category_Id,
Category_Type=indlist[i].Category_Type,
District_Id=indlist[i].District_Id,
EmailID=indlist[i].EmailID,
Estate_Name=indlist[i].Estate_Name,
GIDC_Area=indlist[i].GIDC_Area,
GPCB_Id=indlist[i].GPCB_Id,
Industry_Name=indlist[i].Industry_Name,
IndustryId=indlist[i].IndustryId,
Mobile_No=indlist[i].Mobile_No,
Owner_Group=indlist[i].Owner_Group,
Pan_Id=indlist[i].Pan_Id,
Password=indlist[i].Password,
Pincode=indlist[i].Pincode,
Plot_No=indlist[i].Plot_No,
Postal_Address=indlist[i].Postal_Address,
Project_Cost=indlist[i].Project_Cost,
Project_Location=indlist[i].Project_Location,
Survey_No=indlist[i].Survey_No,
Taluka_Id=indlist[i].Taluka_Id,
Username=indlist[i].Username,
Village_Id=indlist[i].Village_Id
};
}
return JsonConvert.SerializeObject(indarray, Formatting.Indented);
}
[WebMethod(Description = "Get List of industries with fileds industry id and industry name")]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string GetIndustryList()
{
List<tbl_Industry_Registration> indlist = new List<tbl_Industry_Registration>();
indlist = gpcb1.tbl_Industry_Registration.ToList();
Industry[] indarray = new Industry[indlist.Count];
for (int i = 0; i < indlist.Count - 1; i++)
{
indarray[i] = new Industry
{
IndustryId = indlist[i].IndustryId,
IndustryName = indlist[i].Industry_Name
};
}
JavaScriptSerializer js = new JavaScriptSerializer();
string strJSON = js.Serialize(indarray);
return strJSON;
//return JsonConvert.SerializeObject(indarray, Formatting.Indented);
}
public class Industry
{
public int IndustryId { get; set; }
public string IndustryName {get;set;}
}
}
error is
Request format is unrecognized for URL unexpectedly ending in '/GetIndustryList'
Please provide me solution...
Upvotes: 0
Views: 1348
Reputation: 2856
solved....
I added following lines in Web.config file
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
and it started working..
Upvotes: 1