Web Service to load data to main - InfoPath Dev
in

InfoPath Dev

Web Service to load data to main

Last post 01-12-2006 10:56 AM by Richard. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 12-30-2005 03:08 PM

    Web Service to load data to main

    I have created a form from a given schema, (foo.xsd).
    Now, I want to be able to load the main DOM with the xml received from a web service. this xml conforms to foo.xsd but each sample xml may or may not use all the elemts,, So, I do not want infopath to infer a schema for it.. !.

    Unfortunately , returning the webservice with the foo.xsd class does not work, .. ! ( some compatibility issues with the MSXML )..

    I thought that the best way was to have the web service return the result as string, But , there is no tool to convert the string to xml ?

    Is there a way to open a form with data that comes from the web service ?



  • 12-31-2005 09:03 AM In reply to

    Re: Web Service to load data to main

    Inferring only occurs when designing when going through the data connection wizard. So, one approach would be when going through the wizard to hook in your webservice to set sample data such that you entire schema can be inferred. Once that is done, you should be ok.

    Another thing you can do is pass a strongly typed dataset from your .NET webservice into you IP form. That way the entire schema as defined is picked up and it should not be inferred. Correct me if I am wrong there. This is just my opinion but I usually do not return strongly typed datasets from webserivces because a strongly typed dataset is specific to .NET and I like to make sure that my webservices can be consumed by any platform. Although since there is nice integration with IP and webservices that return strongly typed datasets...

    Oh, there is a way get an XML string into an XML document via stript. Got to take care of something...will post in a couple.
    Jason
    http://www.k2distillery.com/
  • 01-01-2006 06:04 AM In reply to

    Re: Web Service to load data to main

    Ok, here are some code snippets that you can try to use. You should be able to write a web webservice that returns an XML string and then you can subsequently push that into you InfoPath form's main DOM. They are in VBScript.

    This first method will allow you take an XML string and append it into the main DOM. When calling this method sParentNodePath would take an XPath query to a group and subsequently add a row into a repeating section. Although this does not do exactly what you are looking for, you should get the point.

    Sub CreateRow(sXML, sParentNodePath)

    'Create a new row
    dim oXml
    set oXml = XDocument.CreateDOM()
    oXml.async = false
    oXml.loadXML(sXML)

    'add the row to the DOM
    XDocument.DOM.selectSingleNode(sParentNodePath).appendChild(oXml.documentElement)

    End Sub

    Here is more code. What you can do with this code is modify it such that you take a DOM from a secondary data source and if it conforms to the main data source, you can push the values from the secondary datasource into the main data source.

    Dim existingDataFields
    Set existingDataFields = XDocument.DOM.selectSingleNode(...Path to root node...)
    Call domTemplate.setProperty("SelectionNamespaces", MY_XML_NAMESPACE)

    Dim newDataFields
    Set newDataFields = domTemplate.selectSingleNode(...Path to root node...)
    Call existingDataFields.parentNode.replaceChild(newDataFields.cloneNode(true), existingDataFields)

    There are tons of things you can do.

    HTH
    Jason
    http://www.k2distillery.com/
  • 01-09-2006 04:33 PM In reply to

    Re: Web Service to load data to main

    thanks for your response,,
    I was able to loadxml , but replacing the child of the main dom gives me error
    here is what I have:

    IXMLDOMDocument3 wsDOM = (IXMLDOMDocument3) thisXDocument.GetDOM("GetMarkLogicString");

    wsDOM.setProperty("SelectionNamespaces", "......");
    IXMLDOMNode tempnode = wsDOM.selectSingleNode("//dfs:myFields//dfs:dataFields");

    IXMLDOMDocument oXml = thisXDocument.CreateDOM();
    oXml.async = false;
    oXml.loadXML(tempnode.text);

    IXMLDOMNode NewChild = oXml.documentElement.selectSingleNode("/ClinicalDocument");

    IXMLDOMNode OldChild = thisXDocument.DOM.selectSingleNode("/my:myFields//ns1:ClinicalDocument");

    OldChild.parentNode.replaceChild(NewChild,OldChild);
  • 01-10-2006 12:12 AM In reply to

    Re: Web Service to load data to main

    Hi,

    The problem is the namespace one has ns1: and not the other!

    For XML it's not the same things!

    You need to add or remove the namespace in one of your IXMLDOMNode!

    Me I do this with a XSL! If you want I can send you I have the two for add and remove!

    ++
    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 01-10-2006 11:22 AM In reply to

    Re: Web Service to load data to main

    Thanks Thierry,
    the xml coming from the web service, has the following:
    <ClinicalDocument xmlns="urn:hl7-org:v3" ....... >

    please send me your sample..

    thanks.


  • 01-10-2006 10:36 PM In reply to

    Re: Web Service to load data to main

    Hi,

    No problem here is the nonamespace xsl you have only to change my by your prefix and change the namespace too.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:my="http://..." exclude-result-prefixes="my">
    <xsl:template match="/" >
    <xsl:apply-templates />
    </xsl:template>
    <xsl:template match="*">
    <xsl:element name="{local-name()}">
    <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
    <xsl:value-of select="."/>
    </xsl:attribute>
    </xsl:template>
    </xsl:stylesheet>


    ++

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 01-11-2006 10:58 AM In reply to

    Re: Web Service to load data to main

    Are you suggesting that I remove the prefixes from the main DOM or remove it from the secondary. ?
  • 01-11-2006 10:32 PM In reply to

    Re: Web Service to load data to main

    Hi,

    Sorry I have make an error I have not good read! You must change the secondary DS so you need to add a namespace. Here is the following:

    quote:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-06-14T14-11-47" xmlns:ns3="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-01-05T09:29:52" xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition" xmlns:ns2="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns4="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://zefix.powernet.ch/WebServices" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-07-06T05:50:54" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
    <xsl:template match="/">
    <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="*">
    <xsl:element name="{concat('ns1:', local-name())}">
    <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="@*">
    <xsl:attribute name="{concat('ns1:', local-name())}"><xsl:value-of select="."/></xsl:attribute>
    </xsl:template>
    </xsl:stylesheet>


    You need to change the namespace declaration by your (the best is make a copy of the namespace declaration in template.xml) and I don't know if your attribut need to have ns1: in the name (see in template.xml too)!

    ++

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 01-12-2006 10:56 AM In reply to

    Re: Web Service to load data to main

    thanks for the update, However, Before I got to try the xsl, it seems that I have a problem with loadXML :
    Here is the code:

    IXMLDOMDocument oXml = (IXMLDOMDocument) thisXDocument.CreateDOM()oXml.async = false;
    oXml.resolveExternals=true;
    if ( oXml.loadXML(tempnode.text) == true )
    thisXDocument.UI.Alert("Successfull load");
    else
    thisXDocument.UI.Alert(oXml.parseError.reason);

    Reason Error:
    While loading the schema 'CDA.xsd' following error has occured
    the process can not access the file because it is being used by another process

    And If I set oXml.resolveExternals=false, then certain xsd types are not defined and I will get error from the xml parser .

Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.