Enjoy Every Sandwich

Thoughts on SQL, XML, .NET and sometimes beer.

<October 2008>
SuMoTuWeThFrSa
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678


Navigation

Tools

List O'Links

Kent's Other Stuff

Subscriptions

News

Please read these
Notices and Disclamiers

Post Categories

Article Categories



Wednesday, August 04, 2004 - Posts

Kent's Geek Boutique?
Just testing an idea, really, but you be interested in WearWare, DrinkWare and DeskWare branded to the 'Sandwich?

If so.

If not.

posted Wednesday, August 04, 2004 11:50 PM by ktegels

How do you develop a web service that uses unknown types?

Mike Miller asked a doozy of a question and I'm punch drunk from dealing with WSE all day. Apologies in advance. Mike's original posting was in news:f2018958.0408042204.7ee9940f@posting.google.com (caption: "Question for all of you EXPERT.NET architects")

Question: How do you develop a web service that uses unknown types?

ARRGH! Star-Trek (=/\=) Deja-Vu

Saavik: "On the test, sir. Will you tell me what you did? I would really like to know."
McCoy: "Lieutenant, you are looking at the only Starfleet cadet who ever beat the no-win scenario."
Saavik: "How?"
Kirk: "I reprogrammed the simulation so it was possible to rescue the ship."
Saavik: "What?"
David Marcus: "He cheated."

Chris added:

The ideas is that my web service performs a generic function. I want anyone to be able to consume it, but I can't know what type of objects > they are going to pass to in (like I said it performs some generic functionality - I don't want to recompile it ever).

Well, I'm not expert (ask anybody that knows me, they'll agree) but, suppose you service accepted an XSD that described the object in question. You don't really care about the inerds of this, you're just going to extract the schema out of the SOAP envelope, maybe insepct its namespaces references to determine an appropriate object factory (or chain thereof) to pass it off to, do the pass-off and wait for response(s). You could probably even ask the factory to serialize it up for you as an XML fragement.

Of course, you still have to write those factories and the clients will have to know how to deserialize said. Share the class by sharing the Schema.

Doable? Sure! Easy? No. But it meets your requirements -- strictly speaking. :)

I fully expect the SOA police will hunt me down for suggesting this and that I'll be banished from the Don Box Fan Club for life.

Oh by the way, XSD annotated schemas in SQL Server 2000 kind-of does this now.

posted Wednesday, August 04, 2004 10:59 PM by ktegels

Calling Web Services serverd with Self-Signed Certificates

Chris Salek wrote in one of the newsgroups I'm watching (sorry, I've missplaced the posting.) Since this wasn't exactly easy to find, I'm posting my response and code here too.

...Runs without error, but any attempt to call a function after this results in an 'Access Denied' error. [The same username and password works fine from the java client they supplied]...

He's working against a Java Service using Axis. Sounds like a part of the problem I ran into a couple of days ago. Basically, if their certificate is self-issued/self-signed, you're going to have to override .NET's certificate acceptance policy. First, you'll want to create a class like this in your project:

Public Class OverrideCertificatePolicy
  Implements ICertificatePolicy
  Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
    ByVal cert As X509Certificate, ByVal request As WebRequest, _
    ByVal certificateProblem As Integer) _
    As Boolean Implements ICertificatePolicy.CheckValidationResult
    If cert.GetRawCertDataString = ConfigurationSettings.AppSettings("vendorCertValid") Then
      Return True
    Else
      Return False
    End If
  End Function
End Class

Then at somepoint before you call the WebService, you'll need to do this:

  System.Net.ServicePointManager.CertificatePolicy = New OverrideCertificatePolicy

That *should* help, but its not exactly the safest of code to write since it by-passes a fairly essential element in the SSL exchange. That's why I'm doing the GetRawCertDataString comparsion against a known good value for it.

posted Wednesday, August 04, 2004 6:48 AM by ktegels




Powered by Dot Net Junkies, by Telligent Systems