TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

InfoPath: A Developer's Friend

I'm probably the last person on Earth to do this, but..."Hey, InfoPath let's you call Web Services!" :-)

This is actually really slick if you just need something simple like a test client for your .NET code...

public class People : System.Web.Services.WebService {

        public class Person {

        private string _name;

        private int _age;

 

        public string Name {

            get { return _name; }

            set { _name = value; }

        }

 

        public int Age {

            get { return _age; }

            set { _age = value; }

        }

    }

 

    [WebMethod]

    public Person GetPerson(string name) {

        Person p = new Person();

        p.Name = name;

        p.Age = new Random().Next(21, 100);

        return p;

    }
}

  1. Open InfoPath 2003 and design a new form.
  2. Click New from Data Connection...
  3. The Data Connection Wizard starts. Click Web Service, then click Next.
  4. Click Receive and submit data, then click Next.
  5. Enter the URL for the WSDL location (http://localhost/PersonService/People.asmx?WSDL), then click Next.
  6. Select the operation (in this case GetPerson), then click Next.
  7. Enter a query name, then click Next.
  8. Again you are presented with a URL, but this time it is for the "submit data". Leave the value the same, and click Next.
  9. Again you are presented with the operation list (in this case GetPerson) to select, then click Next.
  10. Select field or group, click the Modify button on the right side of the dialog box.
  11. In the Select a field or group dialog box, expand the queryFields and operation tree and click on the parameter (in this case name), then click OK.
  12. In the wizard dialog, click the submit data as string checkbox, then click Next.
  13. Click Finish

When the InfoPath form appears, there will be a region for query field and data field.

  1. Simply drag the queryFields folder on the right window pane into the "drag query fields here" region.
  2. When the dialog appears, click Selection with Controls.
  3. Do the same thing for the dataFields folder in the "drag query fields here region."
  4. From the File menu, click Publish.
  5. Select a location to publish (in this case folder on this computer), then click Next.
  6. Set the destination file name, click Next, then click Finish.
  7. Close the Wizard.


Digg!

posted on Tuesday, August 30, 2005 7:18 PM

Feedback

No comments posted yet.