2

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.. :)

LiverpoolsNumber9
  • 2,384
  • 3
  • 22
  • 34

1 Answers1

1

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

J Benjamin
  • 4,722
  • 6
  • 29
  • 39
  • looks like my xml paste got parsed...sorry about that but the general idea is to use the URLs to direct to the right method, do the logic (whether it be a request for data or a request for an action) and respond with an xml wrapped response. In this case the xml response simply holds a couple ResponseCode objects in the header and the responseBody contains the APIHostname object which is automatically wrapped and returned. – J Benjamin Nov 03 '10 at 17:11
  • (ignore the ApplicationGUID parm) – J Benjamin Nov 03 '10 at 17:13
  • Thanks J - this got me going nicely. So far I've managed to set up a "test SOAP driver" which is read at the other end by a simple aspx page. I'll post the code as an edit now... :) – LiverpoolsNumber9 Nov 04 '10 at 10:08
  • hell if I would have seen earlier that you were a Torres fan I might not have responded lol...just kidding, great to hear I could be helpful (go chelsea) – J Benjamin Nov 04 '10 at 15:04
  • His armband proved he was Red... 2, his bank account proved he was a russian oil billionaire... 0 :P – LiverpoolsNumber9 Nov 08 '10 at 13:36