locked
Programmatically set initial state. RRS feed

  • Question

  • Hi all,

    I'd like to set the initial state on a service I'm creating using CreateService.  I attempted to do it like this, but it didn't work:
     
    Code Snippet

    ServiceInfoType servinfo = new ServiceInfoType(connection.contract);
    string statePartnerXMLFilename=Path.GetTempFileName()+".xml";
    servinfo.PartnerList.Add(new PartnerType(new System.Xml.XmlQualifiedName(statePartnerXMLFilename), "", "dssp:StateService"));



    My reasoning follows from the method for setting the initial partner using a manifest, where Name and Service are set but Contract is left empty.  Unfortunately, it didn't work. 

    What I really want to do is provide an empty state to a new service instance and if I can avoid creating an XML file in the process, that would be good too.  Is there a way to provide the state via an embedded resource?

    thanks,
    R


    Tuesday, August 14, 2007 4:47 PM

Answers

  • You can do this programmatically by making a minor twist to what you already have:

     

    Code Snippet

    ServiceInfoType servinfo = new ServiceInfoType(connection.contract);
    string statePartnerXMLFilename = ServicePaths.Store + "/InitialState.xml.xml";
    servinfo.PartnerList.Add(new PartnerType(Partners.StateService, String.Empty, statePartnerXMLFilename));

     

     

    Note that we have the constraint that initial state partners have to be under the installation folder. However, as George also points out you can do it using embedded resources as well. You can see how to do this in Service Tutorial 6 (in this case we do it with an XSLT but it works the same for any other thing as well).

     

    Henrik

     

     

    Thursday, August 16, 2007 5:50 PM

All replies

  • you can point to any URI, including an embedded resource. We have a service, the AssemblyResource services, that mounts, as web pages, any resources in your service. Then they are available as URIs. Our user guide describes this, plus our service tutorials (we use this commonly for XSLT files, etc)

     

    thanx

    g

     

    Thursday, August 16, 2007 5:35 AM
  • Thank George, that answers half my question. 

    The other half is how to do this programmatically.  I've tried a couple variations on what I did above but the service still seems to be loading the default initial state partner.  I RTFM but didn't see anything other than the approach using a manifest.

    cheers,
    R
    Thursday, August 16, 2007 4:24 PM
  • You can do this programmatically by making a minor twist to what you already have:

     

    Code Snippet

    ServiceInfoType servinfo = new ServiceInfoType(connection.contract);
    string statePartnerXMLFilename = ServicePaths.Store + "/InitialState.xml.xml";
    servinfo.PartnerList.Add(new PartnerType(Partners.StateService, String.Empty, statePartnerXMLFilename));

     

     

    Note that we have the constraint that initial state partners have to be under the installation folder. However, as George also points out you can do it using embedded resources as well. You can see how to do this in Service Tutorial 6 (in this case we do it with an XSLT but it works the same for any other thing as well).

     

    Henrik

     

     

    Thursday, August 16, 2007 5:50 PM