Note that there are some explanatory texts on larger screens.

plurals
  1. POWebMethod receives null in parameters
    text
    copied!<p>I have a web service with a method that has two string parameters. When I'm debugging, I can see in my calling method where it passes two string values into the method, but actually the WebMethod just gets null for both values. Here is some code:</p> <p>WebMethod</p> <pre><code>[WebMethod(Description = "Set username and password for validation purposes.")] public void Login(string uname, string pword) { username = uname; password = pword; } </code></pre> <p>Calling Method</p> <pre><code>NewsletterEmailSubscribers nes = new NewsletterEmailSubscribers(); nes.Login("Username", "Password"); </code></pre> <p>What am I doing wrong here?</p> <p>--EDIT--</p> <p>Adding more code.</p> <p>The web service:</p> <pre><code>[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class NewsletterEmailSubscribers : WebService { private static string username, password; public NewsletterEmailSubscribers() { } /// &lt;summary&gt; /// Logins the specified username. /// &lt;/summary&gt; /// &lt;param name="username"&gt;The username.&lt;/param&gt; /// &lt;param name="password"&gt;The password.&lt;/param&gt; [WebMethod(Description = "Set username and password for validation purposes.")] public void Login(string uname, string pword) { username = uname; password = pword; } /// &lt;summary&gt; /// Adds subscriber email account. /// &lt;/summary&gt; /// &lt;param name="emailAddress"&gt;The email address&lt;/param&gt; /// &lt;param name="newsletterType"&gt;The newsletter they have signed up to receive&lt;/param&gt; /// &lt;param name="validationCode"&gt;The validation code&lt;/param&gt; [WebMethod(Description = "Initial add of subscriber email address and newsletter signing up for.")] public void AddSubscriber( string emailAddress, string newsletterType, string validationCode) { // Check some values //Authenticate user, will throw exception if the user is invalid using (SOAValidation validation = new SOAValidation()) { validation.ValidateConnection(validationCode, username, password, "Full"); } OracleParameterCollection parameters = new OracleParameterCollection(); parameters.AddWithValue("subscriber_email", emailAddress); parameters.AddWithValue("newsletter_type", newsletterType); Database.ExecuteQuery("dw.newsletter_pkg.newsletter_subscriber_add", parameters); } } </code></pre> <p>Webpage using the service (NewsletterEmailSubscribers)</p> <pre><code>private void SubmitEmail(string email) { if (ValidateEmail(email)) { try { NewsletterEmailSubscribers nes = new NewsletterEmailSubscribers(); nes.Login("Username", "Password"); string validationCode; using (Cokesbury.RemoteValidation.Validator validator = new Cokesbury.RemoteValidation.Validator()) { validationCode = validator.ValidationCode(System.Configuration.ConfigurationManager.AppSettings["PasswordSalt"].ToString()); } // submit to db nes.AddSubscriber(email, "FICT", validationCode); // Switch to confirm message mvPage.SetActiveView(vwThankYou); } catch (Exception ex) { mvPage.SetActiveView(vwFail); bool rethrow = ExceptionPolicy.HandleException(ex, "Presentation Services Exception Policy"); if (rethrow) { throw (ex); } } } else lblEmailError.Visible = true; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload