BizTalk-使用具有多个名称空间的xpath提取元素值

问题描述 投票:0回答:1

我在BizTalk中有一个员工味精。在业务流程中,我正在尝试获取字段的值(IBKT_SYSID_PK),但它返回的是空值。请协助。

员工信息:

<ns1:KellyEmployee xmlns:ns2="http://purl.org/dc/elements/1.1/" xmlns:ns0="http://ns.hr-xml.org/2007-04-15" xmlns:ns1="http://ECI.KellyCommon_Employee_Schemas.KellyEmployee" xmlns:ns3="http://www.w3.org/XML/1998/namespace" xmlns:ns4="http://www.w3.org/2000/09/xmldsig#">
  <KellyEmployeeHeader>
    <State>tobeProcessedbySubOrch</State>
    <GUID>4a569a18-5b6a-4b90-9c0c-324cbdcf78e8</GUID>
    <EmployeeStatus>update</EmployeeStatus>
    <Vendor>BH</Vendor>
    <Destination>KSN</Destination>
    <Errors>
      <ErrorType>Business</ErrorType>
      <ErrorCorrection />
    <Error><FldName>EMPL-59637</FldName><Code>302</Code><Msg>Modified Date Mismatch, data might be out of sync between KSN and ATS</Msg></Error></Errors>
    <ErrorInd>true</ErrorInd>
    <WarningInd>false</WarningInd>
    <TransactionID>40047965</TransactionID>
    <LogicalKey>59637</LogicalKey>
    <ECIReceivedTS>2020-02-26T03:42:03</ECIReceivedTS>
    <SkipValidation>true</SkipValidation>
    <BatchID />
    <Action>EMPLUPD</Action>
    <ProcessType>generic</ProcessType>
    <CorrelationID>BH-KSN-59637-update</CorrelationID>
    <ProcessingInstanceID>061b2b42-64c1-4a06-98de-f297949e4c06</ProcessingInstanceID>
    <RetryCount>1</RetryCount>
    <PreventResubmissionInd>true</PreventResubmissionInd>
  </KellyEmployeeHeader>
  <ns0:NewHire>
    <ns0:TypeOfHire xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
    <ns0:NonStandardValue>E_EMPLUPD</ns0:NonStandardValue>
  </ns0:TypeOfHire>
    <ns0:EmployeeInfo xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
    <ns0:PersonName>
      <ns0:GivenName>some</ns0:GivenName>
      <ns0:PreferredGivenName />
      <ns0:FamilyName>newone</ns0:FamilyName>
      <ns0:MiddleName />
      <ns0:Affix type="salutation" />
    </ns0:PersonName>
    <ns0:EmployeeId xsi:type="ns0:EntityIdType">
      <ns0:IdValue name="KSNEmployeeSysID">30072539</ns0:IdValue>
      <ns0:IdValue name="availabilityStatus" />
      <ns0:IdValue name="ATSEMPLID">59637</ns0:IdValue>
      <ns0:IdValue name="additionalSkillNote" />
      <ns0:IdValue name="preferredContactMethodDescr" />
      <ns0:IdValue name="workOpportunityCredit" />
      <ns0:IdValue name="suspendIndicator">N</ns0:IdValue>
    </ns0:EmployeeId>
    <ns0:ContactMethod xsi:type="ns0:ContactMethodType">
      <ns0:Use>Y*q!Z?*Y</ns0:Use>
      <ns0:Location />
      <ns0:Telephone>
        <ns0:FormattedNumber>313 999 1928</ns0:FormattedNumber>
      </ns0:Telephone>
      <ns0:Mobile>
        <ns0:FormattedNumber>
        </ns0:FormattedNumber>
      </ns0:Mobile>
      <ns0:TTYTDD>
        <ns0:FormattedNumber>
        </ns0:FormattedNumber>
      </ns0:TTYTDD>
      <ns0:Fax>
        <ns0:FormattedNumber />
      </ns0:Fax>
      <ns0:InternetEmailAddress>PERSONAL*[email protected]</ns0:InternetEmailAddress>
      <ns0:PostalAddress type="streetAddress">
        <ns0:CountryCode>USA</ns0:CountryCode>
        <ns0:PostalCode>48082</ns0:PostalCode>
        <ns0:Region>MI*q!Z?*null</ns0:Region>
        <ns0:Municipality>troy</ns0:Municipality>
        <ns0:DeliveryAddress>
          <ns0:AddressLine>100 main</ns0:AddressLine>
        </ns0:DeliveryAddress>
      </ns0:PostalAddress>
    </ns0:ContactMethod>
    <ns0:PersonDescriptors>
      <ns0:LegalIdentifiers>
        <ns0:MilitaryStatus />
      </ns0:LegalIdentifiers>
      <ns0:BiologicalDescriptors>
        <ns0:DateOfBirth />
      </ns0:BiologicalDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>recruitingSource</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>recruitingSourceNote</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>minimumSalary</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>minimumSalaryRate</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>minimumSalaryRateDescr</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>emplLastContactedDate</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>resetPasswordIndicator</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>OASInvitationIndicator</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>OASInvitationEmailSubject</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>OASInvitationEmailText</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
      <ns0:OtherDescriptors>
        <ns0:Name>newLinkRequestIndicator</ns0:Name>
        <ns0:Value />
      </ns0:OtherDescriptors>
    </ns0:PersonDescriptors>
    <ns0:Competency name="employeeSkills" required="false">
      <ns0:CompetencyId id="" />
    </ns0:Competency>
    <ns0:EducationHistory>
      <ns0:SchoolOrInstitution>
        <ns0:SchoolName>dorsey</ns0:SchoolName>
        <ns0:LocationSummary>
          <ns0:Municipality>toledo</ns0:Municipality>
          <ns0:Region>OH</ns0:Region>
          <ns0:CountryCode />
        </ns0:LocationSummary>
        <ns0:Degree>
          <ns0:DegreeName>BS*q!Z?*</ns0:DegreeName>
          <ns0:DegreeDate>
            <ns0:AnyDate>1988-12-11</ns0:AnyDate>
          </ns0:DegreeDate>
          <ns0:DegreeMeasure>
            <ns0:EducationalMeasure>
              <ns0:MeasureValue>
                <ns0:NumericValue>0</ns0:NumericValue>
              </ns0:MeasureValue>
            </ns0:EducationalMeasure>
          </ns0:DegreeMeasure>
        </ns0:Degree>
        <ns0:Major>ENG*q!Z?*</ns0:Major>
        <ns0:DatesOfAttendance>
          <ns0:StartDate>
            <ns0:AnyDate>1990</ns0:AnyDate>
          </ns0:StartDate>
          <ns0:EndDate>
            <ns0:AnyDate>1993</ns0:AnyDate>
          </ns0:EndDate>
        </ns0:DatesOfAttendance>
        <ns0:Comments>41687266*q!Z?*589</ns0:Comments>
      </ns0:SchoolOrInstitution>
    </ns0:EducationHistory>
    <ns0:EmploymentHistory>
      <ns0:EmployerOrg>
        <ns0:EmployerOrgName>fridays</ns0:EmployerOrgName>
        <ns0:PositionHistory>
          <ns0:Title>working</ns0:Title>
          <ns0:StartDate>
            <ns0:YearMonth>6</ns0:YearMonth>
            <ns0:Year>1989</ns0:Year>
          </ns0:StartDate>
          <ns0:EndDate>
            <ns0:YearMonth>8</ns0:YearMonth>
            <ns0:Year>2000</ns0:Year>
          </ns0:EndDate>
          <ns0:Compensation>
            <ns0:EndingCompensation />
            <ns0:Comments>*q!Z?*</ns0:Comments>
          </ns0:Compensation>
          <ns0:Verification>
            <ns0:ReasonForLeaving />
          </ns0:Verification>
          <ns0:JobLevelInfo>
            <ns0:Comments />
          </ns0:JobLevelInfo>
          <ns0:Comments>57234979*q!Z?*1198</ns0:Comments>
        </ns0:PositionHistory>
      </ns0:EmployerOrg>
      <ns0:EmployerOrg>
        <ns0:EmployerOrgName>emp 2</ns0:EmployerOrgName>
        <ns0:PositionHistory>
          <ns0:Title>cleaning</ns0:Title>
          <ns0:StartDate>
            <ns0:YearMonth>9</ns0:YearMonth>
            <ns0:Year>1990</ns0:Year>
          </ns0:StartDate>
          <ns0:EndDate>
            <ns0:YearMonth>10</ns0:YearMonth>
            <ns0:Year>1995</ns0:Year>
          </ns0:EndDate>
          <ns0:Compensation>
            <ns0:EndingCompensation />
            <ns0:Comments>*q!Z?*</ns0:Comments>
          </ns0:Compensation>
          <ns0:Verification>
            <ns0:ReasonForLeaving />
          </ns0:Verification>
          <ns0:JobLevelInfo>
            <ns0:Comments />
          </ns0:JobLevelInfo>
          <ns0:Comments>57234980*q!Z?*1199</ns0:Comments>
        </ns0:PositionHistory>
      </ns0:EmployerOrg>
      <ns0:EmployerOrg>
        <ns0:EmployerOrgName>AddedINBH</ns0:EmployerOrgName>
        <ns0:PositionHistory>
          <ns0:Title>titlehere</ns0:Title>
          <ns0:StartDate>
            <ns0:YearMonth>1</ns0:YearMonth>
            <ns0:Year>2000</ns0:Year>
          </ns0:StartDate>
          <ns0:EndDate>
            <ns0:YearMonth>6</ns0:YearMonth>
            <ns0:Year>2003</ns0:Year>
          </ns0:EndDate>
          <ns0:Compensation>
            <ns0:EndingCompensation>0</ns0:EndingCompensation>
            <ns0:Comments>*q!Z?*</ns0:Comments>
          </ns0:Compensation>
          <ns0:Verification>
            <ns0:ReasonForLeaving />
          </ns0:Verification>
          <ns0:JobLevelInfo>
            <ns0:Comments />
          </ns0:JobLevelInfo>
          <ns0:Comments>*q!Z?*1200</ns0:Comments>
        </ns0:PositionHistory>
      </ns0:EmployerOrg>
    </ns0:EmploymentHistory>
  </ns0:EmployeeInfo>
    <ns0:PositionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
    <ns0:ReferenceInfo>
      <ns0:OtherId idOwner="" validFrom="" xsi:type="ns0:EntityIdType">
        <ns0:IdValue name="employeeType">PROSPECT</ns0:IdValue>
        <ns0:IdValue name="employmentStatus">CANDIDATE</ns0:IdValue>
        <ns0:IdValue name="transactionID">40047965</ns0:IdValue>
        <ns0:IdValue name="KSNModifiedTS">2020-01-16T22:11:31-05:00</ns0:IdValue>
      </ns0:OtherId>
      <ns0:JobId idOwner="" xsi:type="ns0:EntityIdType">
        <ns0:IdValue name="jobCode_Employee">CE01</ns0:IdValue>
      </ns0:JobId>
    </ns0:ReferenceInfo>
    <ns0:ManagerInfo>
      <ns0:ManagerId xsi:type="ns0:EntityIdType">
        <ns0:IdValue name="branch_Employee">3311</ns0:IdValue>
      </ns0:ManagerId>
    </ns0:ManagerInfo>
  </ns0:PositionInfo>
    <IBKT_SYSID_PK xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">1234</IBKT_SYSID_PK>
  </ns0:NewHire>
</ns1:KellyEmployee>

业务流程内部使用的Xpath:

sIBKTSysIDPK = xpath(msgKellyEmployeeIn.msgKellyEmployeeIn, "string(/*[local-name()='KellyEmployee' and namespace-uri()='http://ECI.KellyCommon_Employee_Schemas.KellyEmployee']/*[local-name()='NewHire' and namespace-uri()='http://ns.hr-xml.org/2007-04-15']/*[local-name()='IBKT_SYSID_PK' and namespace-uri()='http://www.w3.org/2001/XMLSchemainstance'][1])");

sIBKTSysIDPK字段每次都返回空。需要获取其值1234并将其存储在变量中。

c# xpath biztalk biztalk-2013
1个回答
0
投票

您的Xpath不太正确,IBKT_SYSID_PK的名称空间为空,因此正确的Xpath为

/*[local-name()='KellyEmployee' and namespace-uri()='http://ECI.KellyCommon_Employee_Schemas.KellyEmployee']/*[local-name()='NewHire' and namespace-uri()='http://ns.hr-xml.org/2007-04-15']/*[local-name()='IBKT_SYSID_PK' and namespace-uri()=''][1]

所以您的代码应该是

sIBKTSysIDPK = xpath(msgKellyEmployeeIn.msgKellyEmployeeIn, "string(/*[local-name()='KellyEmployee' and namespace-uri()='http://ECI.KellyCommon_Employee_Schemas.KellyEmployee']/*[local-name()='NewHire' and namespace-uri()='http://ns.hr-xml.org/2007-04-15']/*[local-name()='IBKT_SYSID_PK' and namespace-uri()=''][1])");
© www.soinside.com 2019 - 2024. All rights reserved.