Search code examples
c#.netsoapspml

SPML (service provisioning markup language) / C#.Net help please!


Sorry for virtually begging for help here but I've been tasked to work on the above and cannot find any adequate resources to help me. Here's the details:

  1. The company has Identity management software which provides an SPML (SOAP) 'feed' of changes to user entitities

  2. (If I've got this right) the SPML driver makes a POST request to a URL on my server which sends those changes

  3. Whatever sits under that URL has to then process the posted information (XML)

Point 3 is my bit. I have no idea what to write. Asmx? Aspx? Ashx? Commodore 64 cassette tape? Apparently the SPML driver needs a 200 response - it will get that anyway when the processing has taking place no? Is there anything more to it that I'm not getting?

Any help, pointers, guidance or advising me to give up and get a new hobby, would be much appreciated.

Thanks.

EDIT..............

Have got a simple soap driver going (for the purposes of testing) which posts xml to an aspx page which then, in turn, consumes the POST and saves the xml. Thanks to J Benjamin (below) and http://www.eggheadcafe.com/articles/20011103.asp for the kick-start.

SOAP DRIVER (works on page load)

protected void Page_Load(object sender, EventArgs e)
{    
    XmlDocument doc = new XmlDocument();
    doc.Load(MySite.FileRoot + "testing\\testxml.xml");
    HttpWebRequest req = 
    (HttpWebRequest)WebRequest.Create("http://localhost/mysite/testing/reader.aspx");
    req.ContentType = "text/xml; charset=\"utf-8\"";
    req.Method = "POST";
    req.Headers.Add("SOAPAction", "\"\"");
    Stream stm = req.GetRequestStream();
    doc.Save(stm);
    stm.Close();
    WebResponse resp = req.GetResponse();
    stm = resp.GetResponseStream();
    StreamReader r = new StreamReader(stm);
    Response.Write(r.ReadToEnd());
}

SOAP READER (reads xml posted when called)

protected void Page_Load(object sender, EventArgs e)
{
    String Folderpath = "c:\\TestSOAP\\";
    if (!Directory.Exists(Folderpath))
    {
        Directory.CreateDirectory(Folderpath);
    }
    Response.ContentType = "text/xml";
    StreamReader reader = new StreamReader(Request.InputStream);
    String xmlData = reader.ReadToEnd();
    String FilePath = Folderpath + DateTime.Now.ToFileTimeUtc() + ".xml";
    File.WriteAllText(FilePath, xmlData);

}

The next step is to try consume the SPML service (which is a Java-driven Novell type thing) - if I have any problems, I will post back here!!

Thanks all.. :)


Solution

  • Maybe I'm misunderstanding, but this sounds similar to how I'm handling URLs in my web service. We're handling logic based on URLs, do the logic, wrap it up in XML and respond with the XML object. Here's a simple example (by simple, I mean one of the few that doesn't require authentication)

    The code below simply returns an XML object containing an AppSetting. The XML response is below as well (with some identifying values removed).

            [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "External/Application/{ApplicationGUID}/APIHost/")]
        public Response GetAPIHostName(Request request, string ApplicationGUID)
        {
            Response response = new Response();
            try
            {
                APIHost apiHost = new APIHost
                                              {
                                                  APIHostname = System.Configuration.ConfigurationManager.AppSettings["PlayerAPIHostname"]
                                              };
                response.ResponseBody.APIHost = apiHost;
                response.ResponseHeader.UMResponseCode = (int) UMResponseCodes.OK;
            }
            catch (GUIDNotFoundException guidEx)
            {
                response.ResponseHeader.UMResponseCode = (int)UMResponseCodes.NotFound;
                response.ResponseHeader.UMResponseCodeDetail = guidEx.Message;
            }
            catch (Exception ex)
            {
                UMMessageManager.SetExceptionDetails(request, response, ex);
                if (request != null)
                    Logger.Log(HttpContext.Current, request.ToString(), ex);
                else
                    Logger.Log(HttpContext.Current, "No Request!", ex);
            }
            response.ResponseHeader.HTTPResponseCode = HttpContext.Current.Response.StatusCode;
            return response;
        }
    

    /" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 200 200 localhost