PDA

View Full Version : [CLOSED] Ajax proxy working only in development server



marco.morreale
Sep 18, 2012, 8:53 AM
Hi,
I am using a treepanel with a ajax proxy.

It works when I run it in Visual Studio but when I deploy it to IIS I get the following error on databinding:

"Request format is unrecognized for URL unexpectedly ending in '/GetNodes'. "

Here is my code, taken from ext.net example "http://examples2.ext.net/#/TreePanel/Loaders/WebService/" :


.aspx



<script type="text/javascript">
function getXmlResponseData(response) {
alert(response);
try {
var xmlData = response.responseXML,
root = xmlData.documentElement || xmlData;

return this.readRecords(Ext.decode(root.firstChild.nodeVa lue));
} catch (ex) {
var error = new Ext.data.ResultSet({
total: 0,
count: 0,
records: [],
success: false,
message: ex.message
});

this.fireEvent('exception', this, response, error);

return error;
}
}

</script>

<ext:TreePanel Width="400"
ID="tpFamiglieArticolo"
runat="server"
Title="Categorie di prodotto"
Border="true"
RootVisible="false"
>
<Store>
<ext:TreeStore ID="TreeStore1" runat="server">
<Proxy>
<ext:AjaxProxy Url="~/WebServices/TreeXmlService.asmx/GetNodes">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader >
<CustomConfig>
<ext:ConfigItem Name="getResponseData" Value="getXmlResponseData" Mode="Raw" />
</CustomConfig>
</ext:JsonReader>
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
<Root>
<ext:Node NodeID="0" Text="Root" />
</Root>
</ext:TreePanel>



web service


/// <summary>
/// Summary description for TreeXmlService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 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 TreeXmlService : System.Web.Services.WebService
{

[WebMethod]
public string GetNodes(string node)
{
NodeCollection nodes = new NodeCollection(false);

if (!string.IsNullOrEmpty(node))
{
for (int i = 1; i < 6; i++)
{
Node asyncNode = new Node();
asyncNode.Text = node + i;
asyncNode.NodeID = node + i;
nodes.Add(asyncNode);
}

for (int i = 6; i < 11; i++)
{
Node treeNode = new Node();
treeNode.Text = node + i;
treeNode.NodeID = node + i;
treeNode.Leaf = true;
nodes.Add(treeNode);
}
}

return nodes.ToJson();
}
}

marco.morreale
Sep 18, 2012, 9:49 AM
Actually, I couldn't get work neither the "TreePanel using WebService" example.

I get the same error.

M

marco.morreale
Sep 18, 2012, 10:03 AM
I could get the example working LOCALLY adding


<ActionMethods Read="POST" ></ActionMethods>

but still it doesn't work once deployed.
M

marco.morreale
Sep 18, 2012, 10:25 AM
Maybe the stack trace can help:



[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetNodes'.]
System.Web.Services.Protocols.WebServiceHandlerFac tory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +569481
System.Web.Services.Protocols.WebServiceHandlerFac tory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
System.Web.Script.Services.ScriptHandlerFactory.Ge tHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +203
System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute() +128
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +184

Daniil
Sep 18, 2012, 1:19 PM
Hi Marco,

Are the page and WerService deployed in the same domain?

Can you access the WebService via browser? What is the link?

Also please post the page link.

marco.morreale
Sep 18, 2012, 2:02 PM
Hi Daniil,
the page and the web service are in the same project. I mean in the same web application.

Web Service address is:
http://renoapp/Reno_B2B_ExtNET/TreeXmlService.asmx

page address is
http://renoapp/Reno_B2B_ExtNET/Test.aspx

Vladimir
Sep 18, 2012, 2:31 PM
Add the following to web.config


<webServices>


<protocols>


<add name="HttpGet"/>


<add name="HttpPost"/>


</protocols>


</webServices>

marco.morreale
Sep 18, 2012, 3:10 PM
Please, mark as closed.
Thank you.
M