locked
Xpath Expression Error in Expression Shape in Orchestration. RRS feed

  • Question

  • Hi all,

    In my application i am working with Orchstration and Transform and Schemas. as follows :

    In orchestation there is a map which get executeon one StoredProcedure.

    I am having Message1 in Orchistration and Execure Transform1, out put of Transform1 is stored in Message1.

    Schema and Output is as follows :

    <USP_GetDataFromCacheResponse xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo">
      <USP_GetDataFromCacheResult>
        <DataSet xmlns="http://schemas.datacontract.org/2004/07/System.Data">
          <xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
            <xs:element msdata:IsDataSet="true" name="NewDataSet">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="unbounded" name="NewTable">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element minOccurs="0" name="CDMXML" type="xs:string" />
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:schema>
          <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
            <NewDataSet xmlns="">
              <NewTable>
                <CDMXML><![CDATA[<ns0:GetDataFromCacheResponseMsg xmlns:ns0="http://mcgrawgroup.com/xsd/CDM/v1"><ns0:MessageHeader><ns0:StatusCode>70</ns0:StatusCode><ns0:StatusMessage>StatusMessage_0</ns0:StatusMessage>/ns0:MessageHeader><ns0:GetDataFromCacheResponse><ns0:DataScore><ns0:Subject><ns0:Id>Id_0</ns0:Id><ns0:Name>Name_0</ns0:Name><ns0:PrimaryPhone>PrimaryPhone_0</ns0:PrimaryPhone><ns0:EmailAddress>EmailAddress_0</ns0:EmailAddress><ns0:EmailType>EmailType_0</ns0:EmailType><ns0:Fax>Fax_0</ns0:Fax><ns0:EntityType>C</ns0:EntityType><ns0:FirstName>FirstName_0</ns0:FirstName><ns0:LastName>LastName_0</ns0:LastName><ns0:MiddleName>MiddleName_0</ns0:MiddleName><ns0:BirthDate>1999-05-31</ns0:BirthDate><ns0:Address><ns0:AddressLine1>AddressLine1_0</ns0:AddressLine1><ns0:AddressLine2>AddressLine2_0</ns0:AddressLine2><ns0:City>City_0</ns0:City><ns0:State>AK</ns0:State><ns0:PostalCode>PostalCode_0</ns0:PostalCode><ns0:Country>US</ns0:Country>	<ns0:GeoCode>	<ns0:Latititude>10.4</ns0:Latititude>	<ns0:Longitude>10.4</ns0:Longitude>	</ns0:GeoCode></ns0:Address><ns0:TaxIdNumber>TaxIdNumber_0</ns0:TaxIdNumber><ns0:DateOfBirth>1999-05-31</ns0:DateOfBirth><ns0:SSN4>100</ns0:SSN4></ns0:Subject></ns0:DataScore></ns0:GetDataFromCacheResponse><ns0:ErrorDetails><ns0:ErrorDetail><ns0:ErrorCode>ErrorCode_0</ns0:ErrorCode><ns0:ErrorHeadline>ErrorHeadline_0</ns0:ErrorHeadline><ns0:ErrorDetails>ErrorDetails_0</ns0:ErrorDetails></ns0:ErrorDetail></ns0:ErrorDetails></ns0:GetCreditScoreResponseMsg>]]></CDMXML>
              </NewTable>
            </NewDataSet>
          </diffgr:diffgram>
        </DataSet>
      </USP_GetDataFromCacheResult>
      <ReturnValue>0</ReturnValue>
    </USP_GetDataFromCacheResponse>

    I am willing to work on [CDMXML] element and after extract it from message it will be look like

    <CDMXML><![CDATA[<ns0:GetDataFromCacheResponseMsg xmlns:ns0="http://mcgrawgroup.com/xsd/CDM/v1"><ns0:MessageHeader><ns0:StatusCode>70</ns0:StatusCode><ns0:StatusMessage>StatusMessage_0</ns0:StatusMessage>/ns0:MessageHeader><ns0:GetDataFromCacheResponse><ns0:DataScore><ns0:Subject><ns0:Id>Id_0</ns0:Id><ns0:Name>Name_0</ns0:Name><ns0:PrimaryPhone>PrimaryPhone_0</ns0:PrimaryPhone><ns0:EmailAddress>EmailAddress_0</ns0:EmailAddress><ns0:EmailType>EmailType_0</ns0:EmailType><ns0:Fax>Fax_0</ns0:Fax><ns0:EntityType>C</ns0:EntityType><ns0:FirstName>FirstName_0</ns0:FirstName><ns0:LastName>LastName_0</ns0:LastName><ns0:MiddleName>MiddleName_0</ns0:MiddleName><ns0:BirthDate>1999-05-31</ns0:BirthDate><ns0:Address><ns0:AddressLine1>AddressLine1_0</ns0:AddressLine1><ns0:AddressLine2>AddressLine2_0</ns0:AddressLine2><ns0:City>City_0</ns0:City><ns0:State>AK</ns0:State><ns0:PostalCode>PostalCode_0</ns0:PostalCode><ns0:Country>US</ns0:Country>	<ns0:GeoCode>	<ns0:Latititude>10.4</ns0:Latititude>	<ns0:Longitude>10.4</ns0:Longitude>	</ns0:GeoCode></ns0:Address><ns0:TaxIdNumber>TaxIdNumber_0</ns0:TaxIdNumber><ns0:DateOfBirth>1999-05-31</ns0:DateOfBirth><ns0:SSN4>100</ns0:SSN4></ns0:Subject></ns0:DataScore></ns0:GetDataFromCacheResponse><ns0:ErrorDetails><ns0:ErrorDetail><ns0:ErrorCode>ErrorCode_0</ns0:ErrorCode><ns0:ErrorHeadline>ErrorHeadline_0</ns0:ErrorHeadline><ns0:ErrorDetails>ErrorDetails_0</ns0:ErrorDetails></ns0:ErrorDetail></ns0:ErrorDetails></ns0:GetCreditScoreResponseMsg>]]></CDMXML>

    I am exeracting the value (CDMXML) using XPath expression in exepration shape as 

    xpath(GetCatchResponseCDMMsg.Body,"count(/*[local-name()='USP_PSIC_(GetCatchResponseCDMFromCacheResponse' and namespace-uri()='http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo']/*[local-name()='USP_PSIC_GetCatchResponseCDMFromCacheResult' and namespace-uri()='http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo']/*[local-name()='DataSet' and namespace-uri()='http://schemas.datacontract.org/2004/07/System.Data']/*[local-name()='diffgram' and namespace-uri()='urn:schemas-microsoft-com:xml-diffgram-v1']/*[local-name()='NewDataSet' and namespace-uri()='']/*[local-name()='NewTable' and namespace-uri()='']/*[local-name()='CDMXML' and namespace-uri()=''])");

    if after execution on Transform1 the out message is not having CDMXML in it this XPath expression is throwing error.

    <USP_GetDataFromCacheResponse xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/dbo">
      <USP_GetDataFromCacheResult>
        <DataSet xmlns="http://schemas.datacontract.org/2004/07/System.Data">
          <xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
            <xs:element msdata:IsDataSet="true" name="NewDataSet">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="unbounded" name="NewTable">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element minOccurs="0" name="CDMXML" type="xs:string" />
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:schema>
          <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
            <NewDataSet xmlns="">
                 <NewTable/>
            </NewDataSet>
          </diffgr:diffgram>
        </DataSet>
      </USP_GetDataFromCacheResult>
      <ReturnValue>0</ReturnValue>
    </USP_GetDataFromCacheResponse>

    How to handle this ?


    Thanks and Regards, Nitin.

    Monday, August 17, 2015 6:57 PM

Answers

  • Hi Shankycheil,

    my apologies if you think that way...

    might be i was no able to explain it correctly.

    What i am trying to do is to fire a query on DB using Transform and the output will give me data from DB.

    once i get the response from db i will execute one more transform which will call the xpath.

    it's trough error on xpath if no data available.

    i have found work around for this i am not executing the second tranform if the first transform not returning data.

    Thanks for your help....


    Thanks and Regards, Nitin.

    • Marked as answer by Nitin Surya Tuesday, August 18, 2015 6:55 AM
    Tuesday, August 18, 2015 6:55 AM

All replies

  • Given the number of times you've posted this I'd assumed you'd have solved this. Again I do not understand what the problem is... did you try understanding how XPATH and XML works or you're assuming this to be a BizTalk issue??

    the following XPATH will give you a string

    string sCDMXML = xpath(message, "string(//*[local-name()='CDMXML')");

    this string will be the message and it will not contain any CDATA (you need to read about XML to understand that).

    Now in your orchestration if you have a variable of type XmlDocument called xmlCDMXML then in a message construct shape (expression) you can create a message by

    xmlCDMXML = new System.Xml.XmlDocument();

    xmlCDMXML.LoadXML(sCDMXML);

    and then if you want to create a types message using this it is as simple as assigning this XmlDocument variable to the Message variable.

    I can give you numerous references within BizTalk on how to address such messages but .....

    Regards.


    PS: I have not understood why you need a MAP in the first place.
    • Edited by Shankycheil Tuesday, August 18, 2015 5:06 AM PS
    Tuesday, August 18, 2015 5:04 AM
  • Hi Shankycheil,

    my apologies if you think that way...

    might be i was no able to explain it correctly.

    What i am trying to do is to fire a query on DB using Transform and the output will give me data from DB.

    once i get the response from db i will execute one more transform which will call the xpath.

    it's trough error on xpath if no data available.

    i have found work around for this i am not executing the second tranform if the first transform not returning data.

    Thanks for your help....


    Thanks and Regards, Nitin.

    • Marked as answer by Nitin Surya Tuesday, August 18, 2015 6:55 AM
    Tuesday, August 18, 2015 6:55 AM