The SIF® Zone
creating, assimilating, and promoting excellence in SIF® agent development

Altering version to satisfy SIF compliance AgentRequests tests

rated by 0 users
Not Answered This post has 0 verified answers | 8 Replies | 3 Followers

Top 25 Contributor
6 Posts
Points 90
Andrew Barrett posted on 12-09-2009 15:22

I am using the sifinfo compliance test harness, and one of the tests that is "Remaining" is "AgentRequestsSchoolInfo" with the description of:
    Agent sends a valid 2.1 SchoolInfo request containing 2.*

I am assuming this means that the query request structure needs to be a SIF_Message with Version of 2.1 containing a SIF_Request with SIF_Version of 2.*. However I am not sure how to achieve that. Below is what I have tried.

In my code I have the following:

    ADK.initialize( SIFVersion.SIF21, SIFDTD.SDO_ALL );

    AgentProperties props = getProperties();
    props.setOverrideSifVersions( "2.0r1, 2.1, 2.*" );


The following is the request structure sent (note the SIF_Message Version of 2.0r1 and Request SIF_Version of 2.*):

17:48:05,461 DEBUG Agent$mydxZoneEA7A73E1E44A11DEB0ABDE60049251EC:434 - <SIF_Message  xmlns="http://www.sifinfo.org/uk/infrastructure/2.x" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0r1">
  <SIF_Request>
    <SIF_Header>
      <SIF_MsgId>E57A08AF90634FD7AC771C6983333D3C</SIF_MsgId>
      <SIF_Timestamp>2009-12-09T17:48:05+10:00</SIF_Timestamp>
      <SIF_Security>
        <SIF_SecureChannel>
          <SIF_AuthenticationLevel>0</SIF_AuthenticationLevel>
          <SIF_EncryptionLevel>0</SIF_EncryptionLevel>
        </SIF_SecureChannel>
      </SIF_Security>
      <SIF_SourceId>mydx</SIF_SourceId>
      <SIF_DestinationId>AgentEA7A73E1E44A11DEB0ABDE60049251EC</SIF_DestinationId>
      <SIF_Contexts>
        <SIF_Context>SIF_Default</SIF_Context>
    </SIF_Contexts>
  </SIF_Header>
  <SIF_Version>2.*</SIF_Version>
<SIF_MaxBufferSize>393216</SIF_MaxBufferSize>
<SIF_Query>
  <SIF_QueryObject ObjectName="SchoolInfo">
    <SIF_Element>EstablishmentId</SIF_Element>
  <SIF_Element>@RefId</SIF_Element>
<SIF_Element>@LAInfoRefId</SIF_Element>
</SIF_QueryObject>
</SIF_Query>
</SIF_Request>
</SIF_Message>

When I add the following line to the query:

    query.setSIFVersions(SIFVersion.SIF21);

the following is the request structure sent (note the SIF_Message Version of 2.1 and Request SIF_Version of 2.1):

18:02:19,181 DEBUG Agent$mydxZoneEA7A73E1E44A11DEB0ABDE60049251EC:434 - <SIF_Message  xmlns="http://www.sifinfo.org/uk/infrastructure/2.x" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.1">
  <SIF_Request>
    <SIF_Header>
      <SIF_MsgId>831CAED7D699428D98B44D3AFC13289D</SIF_MsgId>
      <SIF_Timestamp>2009-12-09T18:02:18+10:00</SIF_Timestamp>
      <SIF_Security>
        <SIF_SecureChannel>
          <SIF_AuthenticationLevel>0</SIF_AuthenticationLevel>
          <SIF_EncryptionLevel>0</SIF_EncryptionLevel>
        </SIF_SecureChannel>
      </SIF_Security>
      <SIF_SourceId>mydx</SIF_SourceId>
      <SIF_DestinationId>AgentEA7A73E1E44A11DEB0ABDE60049251EC</SIF_DestinationId>
      <SIF_Contexts>
        <SIF_Context>SIF_Default</SIF_Context>
    </SIF_Contexts>
  </SIF_Header>
  <SIF_Version>2.1</SIF_Version>
<SIF_MaxBufferSize>393216</SIF_MaxBufferSize>
<SIF_Query>
  <SIF_QueryObject ObjectName="SchoolInfo">
    <SIF_Element>EstablishmentId</SIF_Element>
  <SIF_Element>@RefId</SIF_Element>
<SIF_Element>@LAInfoRefId</SIF_Element>
</SIF_QueryObject>
</SIF_Query>
</SIF_Request>
</SIF_Message>

How do I change the SIF_Message to Version 2.1 but leave the Request SIF_Version as 2.*?
Or am I on the wrong track?

  • | Post Points: 25

All Replies

Top 10 Contributor
72 Posts
Points 1,495

Hi,

The ADK is currently designed to automatically set the request version to 2.* for any 2.x agent.  I believe all you need to do is use the one line of code -

ADK.initialize( SIFVersion.SIF21, SIFDTD.SDO_ALL );

 

 

  • | Post Points: 25
Top 25 Contributor
6 Posts
Points 90

Hi Jonathan,

As you can see in my original post, I already have initialised the adk with those parameters.

I am not sure why the messages are even being sent with a version of 2.0r1, when I thought it should be able to do so using 2.1 given that's what I have initialised the adk with. What would cause that?

Is there a way to change the message version attribute without changing the request version at the same time, as happens when I use query.setSIFVersions with changes both?

I have created a minimal set of code printed below followed by the resulting output:

 

package test;

import com.edustructures.sifworks.*;
import com.edustructures.sifworks.school.*;
import java.io.*;
import org.apache.log4j.*;

public class TestAgent extends Agent {
    private Logger log = Logger.getRootLogger();
   
    public TestAgent() {
        super( "mydx" );
        setName( "Test Agent" );       
    }
   
    public void startAgent()
        throws Exception
    {
        super.initialize();

        String zoneId = "the zone id";
        String zoneUrl = "the zone url";
        String srcAgentId = "the source agent id";
       
        log.setLevel(Level.DEBUG);
        ADK.getLog().setLevel(Level.DEBUG);
        ADK.debug = ADK.DBG_ALL;

        AgentProperties props = getProperties();
        props.setMessagingMode( AgentMessagingMode.PULL );
        props.setKeepMessageContent( true );
        props.setOverrideSifVersions( "2.0r1, 2.1, 2.*" );
        Zone zone = getZoneFactory().getInstance(zoneId, zoneUrl);
        zone.connect( ADKFlags.PROV_REGISTER );
        Query query = new Query( SchoolDTD.SCHOOLINFO );
        log.debug(query.getEffectiveVersion());
        //query.setSIFVersions(SIFVersion.parse("2.1"));
        zone.query(query, srcAgentId, 0);
        shutdown( ADKFlags.PROV_UNREGISTER );
    }

    public static void main(String[] args) {
        Logger log = Logger.getRootLogger();
        try
        {           
            ADK.initialize( SIFVersion.SIF21, SIFDTD.SDO_ALL );
            TestAgent agent = new TestAgent();
            agent.startAgent();
            System.exit(0);
        }
        catch( Throwable t )
        {
            StringWriter buf = new StringWriter();
            t.printStackTrace(new PrintWriter(buf));
            log.fatal(buf.toString());
            System.exit(1);
        }
    }
}

 

The output is below:

 

log.debug(query.getEffectiveVersion());

produces:

11:35:29,058 test.TestAgent  DEBUG root:38 - 2.1

 

zone.query(query, srcAgentId, 0);

produces:

11:35:29,900 com.edustructures.sifworks.impl.BaseHttpProtocolHandler DEBUG Agent$mydxZone08369CE0EAC411DE9AB7B03BE21EC7D9:434 - <SIF_Message  xmlns="http://www.sifinfo.org/uk/infrastructure/2.x" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0r1">
  <SIF_Request>
    <SIF_Header>
      <SIF_MsgId>2929177AFF2D4355956305F2173AE2E3</SIF_MsgId>
      <SIF_Timestamp>2009-12-21T11:35:29+10:00</SIF_Timestamp>
      <SIF_Security>
        <SIF_SecureChannel>
          <SIF_AuthenticationLevel>0</SIF_AuthenticationLevel>
          <SIF_EncryptionLevel>0</SIF_EncryptionLevel>
        </SIF_SecureChannel>
      </SIF_Security>
      <SIF_SourceId>mydx</SIF_SourceId>
      <SIF_DestinationId>Agent08369CE0EAC411DE9AB7B03BE21EC7D9</SIF_DestinationId>
      <SIF_Contexts>
        <SIF_Context>SIF_Default</SIF_Context>
    </SIF_Contexts>
  </SIF_Header>
  <SIF_Version>2.*</SIF_Version>
<SIF_MaxBufferSize>393216</SIF_MaxBufferSize>
<SIF_Query>
  <SIF_QueryObject ObjectName="SchoolInfo"/>
</SIF_Query>
</SIF_Request>
</SIF_Message>

Thanks,

Andrew

  • Filed under: ,
  • | Post Points: 25
Top 10 Contributor
72 Posts
Points 1,495

Hi Andrew,

The reason the Message version is set to 2.0r1 is that it is the lowest level of SIF 2.  That way the message is sent to a provider in the zone that may not be running at a higher level such as 2.1.   Everyone in a zone running SIF 2 can understand a 2.0r1 message.  The ADK will automatically 'bump' the message version up if the requested object appeared in the spec after 2.0r1 so the message passes validation.  SEAInfo is an example of this since it appeared in the 2.3 spec.  A request for SEAInfo would use a Message version of 2.3 and a Request version of 2.*.

Hope this helps,

Jonathan

  • | Post Points: 25
Top 25 Contributor
6 Posts
Points 90

Thanks for that explanation Jonathan. At least now I know why it is sending 2.0r1.

However I still have my original issue of passing the sif compliance test, which has the test "Agent sends a valid 2.1 SchoolInfo request containing 2.*". As you can see in my original post, I seem unable to create that combination to pass the test.

So, in short I need to be able to keep the SIF_Request SIF_Version element as 2.*, but make the SIF_Message Version attribute as 2.1. And note that using query.setSIFVersions(SIFVersion.SIF21) set both to 2.1 which also means that the test does not pass.

...the other alternative being, that the sif compliance test should be changed to allow any 2.X version for the attribute.

Thanks, Andrew

  • Filed under: ,
  • | Post Points: 25
Top 10 Contributor
72 Posts
Points 1,495

Andrew,

I am not sure I understand the intent of the compliance test.  You can query for  LearningResourcePackage if you want to see a SIF message Version of 2.1 with a Request version of 2.*.   LearningResourcePackage was added in 2.1. 

 

Jonathan

  • | Post Points: 45
Top 10 Contributor
215 Posts
Points 5,055

I'm not sure I understand this test either. The ADK is working as designed to follow SIF versioning best practices. I have queried those responsible for the test harness for an explanation of this test. I've never seen it before.

Andrew Elmhorst
Chief Architect
Edustructures 

  • | Post Points: 25
Top 25 Contributor
6 Posts
Points 90

Jonathan,

Unfortunately the compliance test at compliance.sifinfo.org requires that test to be passed for each object that I send a request for. There are 7 object types I am interested in so there are 7 corresponding tests that I need to pass.

Based on your previous reply I am starting to think that it is the test that needs to be changed, to allow the SIF_Message Version attribute to be any 2.X value.

However, if there was any way to set the version attribute, rather than getting them to change the test, then that would be great.

Andrew

  • | Post Points: 5
Top 25 Contributor
6 Posts
Points 90

Thanks for querying them Andrew. I look forward to any response.

  • | Post Points: 5
Page 1 of 1 (9 items) | RSS
Copyright ©2006-2009 sifzone.com
Sponsored by Edustructures
We Connect the Systems that Power Education
 
SIF and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.