Get return value from Web Service

N

Nick McCulloch

I have an InfoPath form that submits the form content to a web service. The
web service call inserts the record into a SQL DB. The IDENTITY column
returns the ID of the new record.

My problem is this. I cant seem to be able to retrieve the return value for
a "submit". Can anyone help me with this?

BTW, the form was designed using the "new from data connection" wizard..

regards,
Nick
 
L

lanwalker

The code below describe how to query and read the result of a
webervice(Datasource) with Infopath

//Request information from the webservice
DataObject
doConnection=thisXDocument.DataObjects["DataConnectionName"];

//Fill parameter
doConnection.DOM.selectSingleNode("//*[local-name()='param1']").text =
param1;

//Send the query
doGroup.Query();


//Read the result !
string id =
doConnection.DOM.selectSingleNode("//*[local-name()='ID']");
Alain Vezina
(e-mail address removed)
 
N

Nick McCulloch

Hi Matthew,

I had hooked it up as a "submit data" connection. I've just purchased the
book from Amazon so I'll check this out.

Regards,
Nick
 
S

Sdimitra

Hello Alain,

I have to do also like these, but i don't know how to bind or fill the
parameter to the web service call. From Your Code what is variable param1
stand for.
I am poor in jscript. Follows a fragment of code which i am trying:

function XDocument::OnSubmitRequest(eventObj)
{
//var fieldValue = XDocument.DOM.selectSingleNode(
"/dfs:myFields/dfs:dataFields/so:ResSRR/so:CompnayID");

XDocument.UI.Alert("FieldVal:"+ fieldValue);

//Check the Xml document
XDocument.UI.Alert(XDocument.DOM.xml);
//Get a reference to the SDS bound to the Web Service.
var theDataObject = XDocument.DataObjects.Item("ShowRegionrepresentative");
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:so="urn:uddi-org:api_v2"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-12-23T13:47:22"');

//Set the SelectionNamespaces so that you can find the correct field.
// Note: If the Web service was created with Visual Studio .NET 2003, the
xmlns:s0 namespace is
// http://tempuri.org/PopulateCities/Service1
/*theDataObject.DOM.setProperty("SelectionNamespaces",
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' +
'xmlns:s0="http://tempuri.org/"');
*/
/*var queryValue = theDataObject.DOM.selectSingleNode(
"/dfs:myFields/dfs:queryFields/s0:GetCities/s0:sState" );

queryValue.text = fieldValue.text;*/

theDataObject.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/so:ResSRR/so:CompnayID[1]").text = "181063";
theDataObject.Query();
eventObj.ReturnStatus = true;
// Write your code here
}

Parameter for my Web service is called CompanyId. In my case a runtime error
is occured that Namespace DFS is not found. what should i do?

Thank'x in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top