1

I've seen some posts on timeout errors but nothing I think that will help me. I have a custom web service running on a sharepoint server. It creates site collections and is being called through a nintex workflow. I recieve this error on my web service action.

Failed to invoke web service. Error returned from server: The operation has timed out

Although it says it failed to invoke the web service, the site collection is being created.

public string CreateSiteCollection(string urlroot, string urlname, string database, string primaryadmin, string secondadmin, string language, string description, string title, string template)
{
    //Find language and template code 
    uint lang_code = get_lang_code(language);
    string temp_code = get_temp_code(template);

    try
    {
        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            using (SPSite site = new SPSite(webapp))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    HttpContext.Current = null;
                    site.AllowUnsafeUpdates = true;
                    web.AllowUnsafeUpdates = true;

                    var newSite = site.WebApplication.Sites.Add(siteurl, title, description, lang_code, temp_code, primaryadmin, null, null, secondadmin, null, null);
                }
            }
        });
    }
    catch (Exception e)
    {
        return string.Format("Exception caught: {0}", e);

    }

    return "Site collection created";
} // End of CreateSiteColleciton

I just changed my web service action to not store the output in a variable and then it ran with no error, could something be wrong with returning the string?

  • Why would you not use a credential in Nintex and use the Create Site Collection operation to provision the new site? – Eric Alexander Aug 13 '14 at 18:15
  • Because we have too many web applications and url names. Options for certain languages and thinks like that, we would have to have over a hundred create site collection actions depending on what the user wants. Unless theres a way to not have those dropdowns and be able to insert a variable, thats what this web service allows us to do. – Bobcat88 Aug 13 '14 at 18:20
  • Typically you'd just put a request form in front of it and pass the options through to the action. Was just curious, I think I'd be a viable option instead of custom code to do something you have access to via a third party product. – Eric Alexander Aug 13 '14 at 18:25
  • Yes that was the plan. But our request form allows you to have different site templates and languages. The create site collection action won't let you pass these as references. You must select these by dropdown. – Bobcat88 Aug 13 '14 at 18:27
1

You should use an Asynchronous pattern here. Since you are assigning a value to the response, it expect a value as soon as line is executed. If you use an asynchronous pattern and use the response on success function, then there will not be a timeout issue. Let me know if you need code level help.

  • Thanks for answering, so if I were to store my exception in a string. Then check if that string contains something, return the exception. Else, return "site created". Would that work or am I not understanding? – Bobcat88 Aug 13 '14 at 18:14
  • See in this case, success has two definitions. Success of the web service call and success of the site collection creation. You can determine success of the web service call as asynchronous call success event get fired. Whether the site collection actually got created or not need to be sent from the service as a response header. There you better define a string pattern and get "site created" if it was created and exception if it is not. – Malin De Silva Aug 13 '14 at 18:25
  • I think that was the issue. Just created two sites succesfully, I'm going to do a few more tests later and if they run smoothly I'll accept your response as the answer. Thank you! – Bobcat88 Aug 13 '14 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.