Webservice error

nightrodnightrod Member Posts: 68
edited 2011-05-17 in NAV Three Tier
Hi,

i have build a webapplication using nav webservices.
when i run the application with the visual studio 2010 debugger it works fine.
when i publish it to the web and run it i get this error:
Server Error in '/' Application.

The request failed with HTTP status 403: Forbidden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The request failed with HTTP status 403: Forbidden.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[WebException: The request failed with HTTP status 403: Forbidden.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +1484609
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +221
NavWeb.WS_SalesInv.WS_SalesInvoice_Service.ReadMultiple(WS_SalesInvoice_Filter[] filter, String bookmarkKey, Int32 setSize) in C:\Users\JR\Documents\Visual Studio 2010\Projects\NavWeb\NavWeb\Web References\WS_SalesInv\Reference.cs:195
NavWeb.WebForm1.LoadDataGrid() in C:\Users\JR\Documents\Visual Studio 2010\Projects\NavWeb\NavWeb\WebForm1.aspx.cs:20
NavWeb.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Users\JR\Documents\Visual Studio 2010\Projects\NavWeb\NavWeb\WebForm1.aspx.cs:39
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207


The code using the webservice in VS looks like this:
private void LoadDataGrid()
        {
            // Initialize the Service 

            WS_Page_SalesInvHeader.WS_SalesInvoice_Service MySalesInvoicesService = new WS_Page_SalesInvHeader.WS_SalesInvoice_Service();
            MySalesInvoicesService.UseDefaultCredentials = true;

            //Read Records 
            WS_Page_SalesInvHeader.WS_SalesInvoice[] Invoices = MySalesInvoicesService.ReadMultiple(null, null, 0);

            //Fill Grid 
            GridView1.DataSource = Invoices;

            GridView1.DataBind();
            if (GridView1.Columns.Count > 0)
                GridView1.Columns[0].Visible = false; //Key
            else
            {
                GridView1.HeaderRow.Cells[0].Visible = false;
                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    gvr.Cells[0].Visible = false;
                }
            }
        }

why is it reffering to a file on the local disk of the Visual studio designer??
Who can help me :-k

Comments

  • kinekine Member Posts: 12,562
    I think that it is referring the file because it is compiled with debug info.

    Question is, why the request is "Forbidden". How looks your infrastructure? Where is the NST? Where SQL? Where is the Web application published? May be the problem is SPN and delegation...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nightrodnightrod Member Posts: 68
    The navision server is on a small business server.
    the .net website consuming the webservices is on an external hosted server.
    Maybe its because the visual studio development machine is inside the domain it is working and the webserver is outside it doesnt work?
    How can i configure it in the right way.

    Thanx for your reply!
  • ara3nara3n Member Posts: 9,256
    You need to change your code

    MySalesInvoicesService.UseDefaultCredentials


    needs to be changed
    NetCredentials = new NetworkCredential();
    NetCredentials.UserName = UserName;
    NetCredentials.Password = password;
    NetCredentials.Domain =  domain;
    MySalesInvoicesService.Credentials = NetCredentials;
    

    NetCredentials is System.net.NetWorkCredentials
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • nightrodnightrod Member Posts: 68
    Hi Rashed,

    Works great!!!!
    =D> =D> =D>
    your up for mvp2011.

    Thanx,
    Johan
  • ara3nara3n Member Posts: 9,256
    You are welcome.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.