Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: Sync with Sage Pastel

  1. #1
    nihon is offline Senior Member
    Join Date
    May 2008
    Posts
    150

    Default Sync with Sage Pastel

    When executing the below code I am getting errors:

    C#/VB.NET Code:
    public void CallEvent(string runtimeParams)
            {
                try
                {
                    
    Customer ThisCustomer = ((AspDotNetStorefrontPrincipal)HttpContext.Current.User).ThisCustomer;
     
                    if (
    this.CalloutURL.Trim() != "" && this.Active)
                    {
                        
    String str AppLogic.RunXmlPackage(this.m_XmlPackagenullThisCustomer1""runtimeParamsfalsefalse);
                        
    byte[] data Encoding.UTF8.GetBytes(str);
     
                        
    HttpWebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create(this.m_CalloutURL); //Webrequest must be fully qualified to avoid compile warnings in VB
                        
    webRequest.Credentials CredentialCache.DefaultCredentials;
                        
    webRequest.Method "POST";
                        
    webRequest.ContentLength data.Length;
                        
    webRequest.ContentType "application/x-www-form-urlencoded";
     
     
                        
    // For Async Call
                        // Create the state object.
                        
    ManualResetEvent WaitHndle = new ManualResetEvent(false);
                        
    RequestState rs = new RequestState(WaitHndlethis.Debug);
     
     
                        
    // Put the request into the state object so it can be passed around.
                        
    rs.Request webRequest;
                        
    rs.DataToSend data;
     
                        
    webRequest.BeginGetRequestStream(new AsyncCallback(ReadCallbackRequest), rs);
     
     
                        
    // Issue the async request
                        
    IAsyncResult r = (IAsyncResult)webRequest.BeginGetResponse(new AsyncCallback(AspdnsfEventHandler.RespCallback), rs);
     
                        
    ThreadPool.RegisterWaitForSingleObject(r.AsyncWaitHandle, new WaitOrTimerCallback(AspdnsfEventHandler.ScanTimeoutCallback), rs, (30 1000), true); //30 sec timeout
     
                        
    allDone.WaitOne();
                        
    rs.ResponseStream.Close();
     
                    }
                }
                catch (
    WebException ex) { string str ex.ToString(); }
                catch (
    Exception ex) { string sr ex.ToString(); }
            } 
    The errors I am getting are as follows:

    You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.

    Can anybody help
    Version (Code/DB):
    AspDotNetStorefront ML 8.1.2.0/8.1.2.0

  2. #2
    ken211 is offline Junior Member
    Join Date
    Jul 2010
    Posts
    3

    Default Some detailed info

    just to add some detail:

    the code mentioned in this thread is part of the aspdotnetstorefront wsi automation system. When setting the wsi to execute when checkout complete no action occurs and the web site that is suppose to receive the call is not recieving anything.

    When i debugged the system i noticed that in the line :

    IAsyncResult r = (IAsyncResult)webRequest.BeginGetResponse(new AsyncCallback(AspdnsfEventHandler.RespCallback), rs);

    an error is being raised and the call is not being made.

    I installed the whole aspdotnetstorefront and also wsi as per user manual and also enabled the settings in the web.config file. When i call the ipx.asmx of gthe web site no errors are raised and this means that all is working fine, but still no calls to my site are being raised.

    Pls help.

    Kenneth

  3. #3
    ken211 is offline Junior Member
    Join Date
    Jul 2010
    Posts
    3

    Default AspDotNetStoreFront

    The code displayed here is the standard code of aspdotnetstorefront for the call event. I used the source code of aspdotnetstorefront to see why no calls are being made to the external website.

    I have re-installed all the system step by step as described in the manual and also enabled the wsi as per manual. Still no calls being made to my external website. I am currently using the latest version of aspdotnetstorefront as downloaded from your website.

    Is it possible to obtained a detailed installation procedure on how to install aspdotnetstorefront and enable wsi events.

  4. #4
    scode is offline Junior Member
    Join Date
    Dec 2005
    Posts
    13

    Default

    I know that this thread is almost one year old but I just run into exactly similar problem using 8.0.1.4 ML.

    The callback used to work just fine while the site was on .Net 3.5. But when we switched to .Net 4.0 callback has started failing with "You must write ContentLength bytes to the request stream before calling [Begin]GetResponse." error.

    Everything else seems to be working just.

    Did anyone else experience similar issue?

  5. #5
    scode is offline Junior Member
    Join Date
    Dec 2005
    Posts
    13

    Default

    UPDATE:
    I've fixed the problem by adding <httpRuntime requestValidationMode="2.0" /> to the site (.Net 4.0 based) that receives callbacks from store.

    Quote Originally Posted by scode View Post
    I know that this thread is almost one year old but I just run into exactly similar problem using 8.0.1.4 ML.

    The callback used to work just fine while the site was on .Net 3.5. But when we switched to .Net 4.0 callback has started failing with "You must write ContentLength bytes to the request stream before calling [Begin]GetResponse." error.

    Everything else seems to be working just.

    Did anyone else experience similar issue?

  6. #6
    glennewing is offline Junior Member
    Join Date
    Oct 2005
    Posts
    15

    Default Event Handler problems

    I believe that there are two separate problems, one each at the sending and receiving ends. First, if you run the store under .net 4.0 then you get the You must write ContentLength bytes to the request stream before calling [Begin]GetResponse." error because BeginGetResponse is being called before ReadCallbackRequest completes. This can be fixed if you have source code by moving the call to BeginGetResponse into ReadCallbackRequest. Refer to http://msdn.microsoft.com/en-us/libr...(v=VS.90).aspx, the obvious source of this code. Refer to http://www.developerfusion.com/code/...ttpwebrequest/ for some insight into the use of RegisterWaitForSingleObject. With this suggested fix you should use the AsyncWaitHandle from the IAsyncResult returned by BeginGetRequestStream in the call to RegisterWaitForSingleObject. I am also mystified by the use of two separate ManualResetEvent's, allDone and WaitHndle. Since the response from the event listener is ignored except for debugging, I think that it would be a "good idea" to (optionally) run the transaction in a separate thread to completely eliminate the customer experiencing the delays of the web round trip. Will probably give that a try.

    Is there an established policy about posting substantial chunks of source?

    The ValidationMode issue is at the Listener end.