Web Service method return parameter - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Web Service method return parameter

Last post 09-16-2005 01:04 PM by Patrick Halstead. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 09-12-2005 02:49 PM

    Web Service method return parameter

    Hello everyone,

    I am very new to programming infopath and to xml. Is there a good reference book that shows good examples of how to work with Web
    Services? Or a good book on XML or tutorial about XPath and stuff like that? It seems that in order to integrate Infopath with WebServices and Sharepoint, I need to know those along with XML and XPath and Serializtion/Deserialization, etc. So much stuff.

    Anyhow, now to my question. This is very basic. All I want to do is get the value of a textbox and then after tabbing off of the control to call a web method that checks if customer exists, and if so return an integer=1 else return 0.

    I have created the Web Method that takes an input string parameter and returns an integer parameter. I also have a textbox called txtQuery where the RULE is 'Set Condition = txtCust is not blank' and where the Action is 'Query using a data connection to a Web Service'.
    I have another textbox called txtSubmit which is the same as above, but the Action is 'Submit using a data connection to a Web Service'.
    Both textboxes call the same web method.
    Then I have another textbox called txtReturn which which has a datatype of Integer, and for the Default Value a formula from an 'Insert Field or Group' where the Data Source is the same Web Method the other 2 txtboxes called.

    Now when I tab off of the txtQuery my Web Method gets called and is passed the value in the textbox. However when I debug my C# app, I notice that the input value is always a NULL string. The method calls a Stored Procedure to check if the customer exists and then returns an int to the txtReturn correctly. The problem with this is that I need to be able to send the value of the txtQuery to my web method, but it doesn't.

    If I insert something tab off of the txtSubmit and debug my C# app, I see that the input string is passed correctly, but now the txtReturn is not set.

    I have already created another Web Method where it populates a drop down list with all the customers on my Infopath form, but since there are like 200 customers, the list takes awhile to load and when you choose a customer, it takes like 1 minute to populate. This is not desirable.

    Anyhow, if anyone knows how to solve this or has a better solution, please let me know. Its such a simple question, but takes forever to figure out, and you can't find really good examples of this material online. There are examples but since I'm new to this stuff, its kinda confusing.
    Recap: All I want to do is check if what the user entered in a textbox is a valid customer, and if so, either change views or enable controls on the Infopath form.

    Also, sorry for such a long post, I just wanted to make sure I had enough details.
    Oh yeah, a recommended book or links for understanding how to integrate Infopath using WebService and Sharepoint would also be nice.

    Oh yeah, I'm glad to be a part of this forum. Seems very helpful!

    Thanks in advance,
  • 09-12-2005 08:06 PM In reply to

    Re: Web Service method return parameter

    This book is pretty good and gets to the point quickly -http://www.bookpool.com/sm/0321113594

    No worries on the long post, I know I have done longer. When you added txtQuery to your InfoPath form, is that field "bound" to your main data source or your seconday data source? When I ask secondary data source, go to the InfoPath task pane >> click data source link >> in the data source drop down there will be a list, select the web service/secondary data source you are working with >> in there you should see queryfields and datafields >> open up the query fields and drag the correct field over to your form.

    When you connect to a web service in InfoPath, InfoPath creates an XML schema for the parameters of your web service. The queryfields will match your web service paramters. The datafields is what ever is returned from your web service.

    If you drag and drop the field from the queryfields, the value you enter will be sent to your web service.

    Hope that helps...
  • 09-12-2005 10:14 PM In reply to

    Re: Web Service method return parameter

    Wow that helped alot. I didn't know I could click Data Source link from task pane and then choose the Data Source that I need and then drag or right-click and tell what type of control I want to add to the form (ex. textbox, drop down list, list box). I did exactly what you said by creating a textbox for both the queryFields (input parameter) and dataFields (output parameter) and then I just added to the queryField textbox a RULE to run ACTION 'Query using a data connection: CheckCustomerNo (my web method)' and viola, it worked. Geez I was trying to do it the hard way before. I guess my controls before did not reference the correct 'Field name' and I tried to add too many RULES. Anyhow, WOOHOO. Thanks a bunch vt_asparagus. You just made my day. I've was working on this for like 2 days and couldn't figure it out....Thank goodness for forums....

    Sorry, but I have another question. Now that I can get the return value from my web method, I added a RULE to the return value:
    When return value = -1
    1)Show dialog box. Customer does not exist. Please enter another.
    2)Set field's value: custnumber=""
    Somehow when I get the return value back, the form doesn't run the OnAfterChange() event which triggers my new RULE. When I go into the return value textbox and type -1 and hit <ENTER> or tab, the event fires and the RULES trigger. I was wondering do I have to edit the OnAfterChange() event using MSE(Microsoft Script Editor) to make sure that my RULE gets triggered after I validate my custnumber textbox? Or can I do without using MSE?
    If so, an example would be great, but if not thanks anyhow!

    Oh yeah, I also picked up this book earlier today:

    I might switch it out for this one:

    Anyhow thanks again vt_asparagus!!!!
  • 09-13-2005 05:03 AM In reply to

    Re: Web Service method return parameter

    Hey no problem...I live to serve.

    I started out with that InfoPath book you put up. It is great and have referred it to my clients that are just starting to use InfoPath.

    Sometime you cannot do what I suggested but it is a recommend path to go.

    Ummm...where go you have this RULE defined? How about trying to put that RULE on the same control, right after the RULE, where the web service query is executed from.
  • 09-13-2005 07:33 AM In reply to

    Re: Web Service method return parameter

    You're correct again....geez. I was placing the RULE to the results textbox instead of the query textbox DOH! I didn't even think about that. I assumed that it would make sense to do it on the results textbox. Man you're super helpful. Now I just have to play around and add another rule so that the user doesn't have to click OK twice when the Customer does not exist error pops up. Its only doing it b/c before since there's a -1 in the results box, the popup shows up and then when the user enters another customer that does not exist, the results gets assigned to -1 again and so the popup shows up once more. Anyhow that shouldn't be any big problem for me.

    I'm sure I'll have other questions lined up later on, but for now thanks.

    Thanks a bunch, once more vt_asparagus!

  • 09-13-2005 09:49 AM In reply to

    Re: Web Service method return parameter

    FYI...the reason why you had to do that is because if you put the RULE on the other control there is nothing there is no event fired to execute the RULE. Hope that makes sense. That book will go over everything we talked about plus MSN has some great labs:

  • 09-13-2005 01:48 PM In reply to

    Re: Web Service method return parameter

    Yeah that makes total sense.
    Thanks for the tips!
  • 09-14-2005 10:46 PM In reply to

    Re: Web Service method return parameter

    Very Tender Asparagus,
    Great to have you on board!

    Patrick Halstead [InfoPath MVP]
    Patrick Halstead
    Project Manager at Qdabra
  • 09-15-2005 06:31 AM In reply to

    Re: Web Service method return parameter

    Virginia Tech Asparagus (nickname of the family for three generations)...but very tender is not too bad either.
  • 09-16-2005 01:04 PM In reply to

    Re: Web Service method return parameter

    :) Sorry, you caught me at dinner time and we were eating asparagus... :) Hilarious!

    Patrick Halstead [InfoPath MVP]
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.