none
TFS Webservice: Clientservice4 - Error: TF51313

    Domanda

  • Hello,

    I try to work with the Webservice of the TFS (.../WorkItemTracking/v4.0/ClientService.asmx). I've sniffed some packages from Visual Studio and build my request like VS does. Unfortunately I still get: "TF51313: The request ID is incorrect or not recognized.".

    Here is the request VS does:

    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Header>
    <RequestHeader xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03">
    <Id>
    uuid:a60c8d8f-fd85-47e9-ba09-ecc598a73d37</Id>
    </RequestHeader>
    </s:Header>
    <s:Body>
    <QueryWorkitems xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03">
    <psQuery>
    <LinksQuery Type="maycontain" RecursionID="2" xmlns="">
    <LeftQuery>
    <Group GroupOperator="and">
    <Expression Column="System.AreaId" FieldType="288" Operator="under">
    <Number>726</Number>
    </Expression>
    </Group>
    </LeftQuery>
    </LinksQuery>
    </psQuery>
    <metadataHave>
    <MetadataTableHaveEntry>
    <RowVersion>380879</RowVersion>
    <TableName>Hierarchy</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>221880</RowVersion>
    <TableName>Fields</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>380125</RowVersion>
    <TableName>HierarchyProperties</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>381747</RowVersion>
    <TableName>Constants</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>381316</RowVersion>
    <TableName>Rules</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>381749</RowVersion>
    <TableName>ConstantSets</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>282121</RowVersion>
    <TableName>FieldUsages</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>380127</RowVersion>
    <TableName>WorkItemTypes</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>380168</RowVersion>
    <TableName>WorkItemTypeUsages</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>379399</RowVersion>
    <TableName>Actions</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>4145</RowVersion>
    <TableName>LinkTypes</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>380595</RowVersion>
    <TableName>WorkItemTypeCategories</TableName>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <RowVersion>380604</RowVersion>
    <TableName>WorkItemTypeCategoryMembers</TableName>
    </MetadataTableHaveEntry>
    </metadataHave>
    </QueryWorkitems>
    </s:Body>
    </s:Envelope>
    


    And here is the request I generate with my code:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
    <RequestHeader xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03">
    <Id xmlns="">
    uuid:a25cbd61-2d06-496c-9dd7-139cd5115fe9</Id>
    </RequestHeader>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <QueryWorkitems xmlns="http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03">
    <psQuery>
    <LinksQuery Type="maycontain" RecursionID="2" xmlns="">
    <LeftQuery>
    <Group GroupOperator="and">
    <Expression Column="System.AreaId" FieldType="288" Operator="under">
    <Number>726</Number>
    </Expression>
    </Group>
    </LeftQuery>
    </LinksQuery>
    </psQuery>
    <useMaster>
    false</useMaster>
    <metadataHave>
    <MetadataTableHaveEntry>
    <TableName>Hierarchy</TableName>
    <RowVersion>380879</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>Fields</TableName>
    <RowVersion>221880</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>HierarchyProperties</TableName>
    <RowVersion>380125</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>Constants</TableName>
    <RowVersion>381747</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>Rules</TableName>
    <RowVersion>381316</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>ConstantSets</TableName>
    <RowVersion>381749</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>FieldUsages</TableName>
    <RowVersion>282121</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>WorkItemTypes</TableName>
    <RowVersion>380127</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>WorkItemTypeUsages</TableName>
    <RowVersion>380168</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>Actions</TableName>
    <RowVersion>379399</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>LinkTypes</TableName>
    <RowVersion>4145</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>WorkItemTypeCategories</TableName>
    <RowVersion>380595</RowVersion>
    </MetadataTableHaveEntry>
    <MetadataTableHaveEntry>
    <TableName>WorkItemTypeCategoryMembers</TableName>
    <RowVersion>380604</RowVersion>
    </MetadataTableHaveEntry>
    </metadataHave>
    </QueryWorkitems>
    </s:Body>
    </s:Envelope>
    

    Finally here is my code:

    ClientService4SoapClient client2 = new ClientService4SoapClient();
    
    client2.ClientCredentials.Windows.ClientCredential.UserName = "me";
    client2.ClientCredentials.Windows.ClientCredential.Password = "123";
    client2.ClientCredentials.Windows.ClientCredential.Domain = "mydom";
    
    var request = new QueryWorkitemsRequest();
    request.psQuery = XElement.Parse(@"
    <LinksQuery Type=""maycontain"" RecursionID=""2"" xmlns="""">
     <LeftQuery>
      <Group GroupOperator=""and"">
       <Expression Column=""System.AreaId"" FieldType=""288"" Operator=""under"">
        <Number>726</Number>
       </Expression>
      </Group>
     </LeftQuery>
    </LinksQuery>
    ");
    
    using (OperationContextScope scope = new OperationContextScope((IContextChannel)client2.InnerChannel)) {
    string temp = "<Id>uuid:"+Guid.NewGuid()+"</Id>";
    MessageHeader header = MessageHeader.CreateHeader("RequestHeader", "http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03", XElement.Parse(temp));
    OperationContext.Current.OutgoingMessageHeaders.Add(header);
    request.metadataHave = new MetadataTableHaveEntry[]{
    new MetadataTableHaveEntry() {RowVersion = 380879, TableName = "Hierarchy"},
    new MetadataTableHaveEntry() {RowVersion = 221880, TableName = "Fields"},
    new MetadataTableHaveEntry() {RowVersion = 380125, TableName = "HierarchyProperties"},
    new MetadataTableHaveEntry() {RowVersion = 381747, TableName = "Constants"},
    new MetadataTableHaveEntry() {RowVersion = 381316, TableName = "Rules"},
    new MetadataTableHaveEntry() {RowVersion = 381749, TableName = "ConstantSets"},
    new MetadataTableHaveEntry() {RowVersion = 282121, TableName = "FieldUsages"},
    new MetadataTableHaveEntry() {RowVersion = 380127, TableName = "WorkItemTypes"},
    new MetadataTableHaveEntry() {RowVersion = 380168, TableName = "WorkItemTypeUsages"},
    new MetadataTableHaveEntry() {RowVersion = 379399, TableName = "Actions"},
    new MetadataTableHaveEntry() {RowVersion = 4145, TableName = "LinkTypes"},
    new MetadataTableHaveEntry() {RowVersion = 380595, TableName = "WorkItemTypeCategories"},
    new MetadataTableHaveEntry() {RowVersion = 380604, TableName = "WorkItemTypeCategoryMembers"}                };
    
    var result2 = await client2.QueryWorkitemsAsync(request);
    

    Any suggestions, why I still get this error? Using the .Net TFS Library is no option, because I'm not able to load NotSystemDlls.

    Thanks for your help!

    giovedì 12 aprile 2012 06:31

Risposte

  • Hallo Robert,

    leider steht mir die .Net Library für den TFS nicht zur Verfügung. Daher bin ich auf den direkten Zugriff auf die Services angewiesen. Das Problem konnte inzwischen gelöst werden.

    In dem von mir erzeugten request ist das xml-Element <Id> mit einem leeren Namespace versehen (xmlns=""). Dieser wird durch die Funktion XElement.Parse() generiert. Fügt man das Id element manuell dem XML Dokument hinzu, wird dieses Namespaceattribut nicht generiert und die Abfrage funktioniert.

    Danke für deine Hilfe

    Jan

    • Contrassegnato come risposta _Jan_ mercoledì 27 giugno 2012 15:04
    mercoledì 27 giugno 2012 15:04

Tutte le risposte

  • Hallo Robert,

    leider steht mir die .Net Library für den TFS nicht zur Verfügung. Daher bin ich auf den direkten Zugriff auf die Services angewiesen. Das Problem konnte inzwischen gelöst werden.

    In dem von mir erzeugten request ist das xml-Element <Id> mit einem leeren Namespace versehen (xmlns=""). Dieser wird durch die Funktion XElement.Parse() generiert. Fügt man das Id element manuell dem XML Dokument hinzu, wird dieses Namespaceattribut nicht generiert und die Abfrage funktioniert.

    Danke für deine Hilfe

    Jan

    • Contrassegnato come risposta _Jan_ mercoledì 27 giugno 2012 15:04
    mercoledì 27 giugno 2012 15:04
  • Hello,

    you are GREAT !!!!!!!!!!!!!! You are my Hero of the day.I have been fiddling around for days, when I came across with your post. This Webservice for the WorkItemStore is really creepy. Getting rid of

     xmlns=""

    does the trick.


    Btw. XElement.Parse will still add a empty xmlns=

    So you should set the same namespace in <Id xmlns=\"http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03\">as of given by the MessageHeader.CreateHeader. Then, the xmlns will be left out when it's sent.


    using (OperationContextScope scope = new OperationContextScope(WorkItemStore.InnerChannel)) { //http://social.msdn.microsoft.com/Forums/vstudio/de-DE/0e517bc0-baac-4101-898a-642baada2f9a/tfs-webservice-clientservice4-error-tf51313?forum=vstfsde&prof=required string temp = "<Id xmlns=\"http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03\">uuid:" + Guid.NewGuid() + "</Id>"; MessageHeader header = MessageHeader.CreateHeader("RequestHeader", "http://schemas.microsoft.com/TeamFoundation/2005/06/WorkItemTracking/ClientServices/03", XElement.Parse(temp)); OperationContext.Current.OutgoingMessageHeaders.Add(header);

    }



    Kind regards,

    Christian




    • Modificato TVDAG sabato 31 maggio 2014 23:14
    sabato 31 maggio 2014 22:39
  • Hello,

    one more question: How do you figure the ProjectId respectively the AreaId for the Query? I could not find that information inside a TeamProject entity.

    Kind regards,


    Christian
    • Modificato TVDAG sabato 31 maggio 2014 23:15
    sabato 31 maggio 2014 22:56