tags:

views:

7848

answers:

4

I'm working with a third party to integrate some of our systems with theirs and they provide us with a SOAP interface to make certain requests and changes in their connected systems. The problem for me is that they do not supply a WSDL-file for me to work against. If I had a WSDL-file it would be a simple matter just to run the supplied .NET command (wsdl.exe) and generate a proxy class to interact with the service.

Is there an "easy" way to do this without a WSDL-file? I have all the functions that we can access and what parameters I need to send and what I should expect in return.

Is it common to have a SOAP-service without WSDL-files? (I'm asking this since we're going to add more external systems into the mix in the future)

Has anyone done a proxy-class or any other form of client against a WDSL-less service and have any good pointers on how to do it?

A: 

I haven't built a SOAP interface without access to a WSDL file, but the format is fairly well-documented. Your best bet might be to create a simplified WSDL file of your own that reflects what you know of the service you're subscribing to....

If you decide to go this route, an existing stackoverflow question points at some tools for validating your WSDL.

cori
+5  A: 

If you write a class that derives from System.Web.Services.Protocols.SoapHttpClientProtocol (and has the correct attributes, e.g., WebServiceBinding, SoapDocumentMethod, etc. applied to it and its methods), you can fairly easily call SOAP methods without needing the WSDL file.

The easiest way to do this would probably be to write your own ASP.NET web service that replicates the third party's SOAP API, generate a proxy class from it, then manually edit the file to ensure that the URL, namespaces, method names, parameter types, etc. are correct for the third-party API you want to call.

Bradley Grainger
A: 

Hi, the code here is in VB.NET but I think you'll get the idea. The following is a client that invokes the 'processConfirmation' method and it expects a response (MyBase.SendRequestResponse).

Imports Microsoft.Web.Services3
Imports Microsoft.Web.Services3.Addressing
Imports Microsoft.Web.Services3.Messaging

Namespace Logic
    Public Class HTTPClient
        Inherits Soapclient

        Sub New(ByVal destination As EndpointReference)
            MyBase.Destination = destination
        End Sub

        <SoapMethod("processConfirmation")> _
        Public Function processConfirmation(ByVal envelope As SoapEnvelope) As SoapEnvelope
            Return MyBase.SendRequestResponse("processConfirmation", envelope)
        End Function
    End Class
End Namespace

And you use it by doing the following:

Dim hc As New HTTPClient(New Microsoft.Web.Services3.Addressing.EndpointReference(New System.Uri("http://whatever.srv")))

Dim envelope As New Microsoft.Web.Services3.SoapEnvelope
Dim doc As New Xml.XmlDocument
doc.LoadXml("<hey>there</hey>")
envelope.SetBodyObject(doc)

Dim return_envelope As Microsoft.Web.Services3.SoapEnvelope = hc.processConfirmation(envelope)

I think this should work .... success!

SpoBo
-1: This requires WSE 3.0, which is obsolete, and should not be used unless there are no other choices.
John Saunders
A: 

string EndPoints = "http://203.189.91.127:7777/services/spm/spm";

string New_Xml_Request_String = " " + DateTime.Now.ToString("o").Remove(19, 14) + "" + Source + "" + Destincation + "";

protected string HttpSOAPRequest_Test(string xmlfile, string proxy) { try { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.InnerXml = xmlfile.ToString(); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(EndPoints); req.Timeout = 100000000; if (proxy != null) req.Proxy = new WebProxy(proxy, true); req.Headers.Add("SOAPAction", ""); req.ContentType = "application/soap+xml;charset=\"utf-8\""; req.Accept = "application/x-www-form-urlencoded"; //"application/soap+xml"; req.Method = "POST"; Stream stm = req.GetRequestStream(); doc.Save(stm); stm.Close(); WebResponse resp = req.GetResponse(); stm = resp.GetResponseStream(); StreamReader r = new StreamReader(stm); string myd = r.ReadToEnd(); return myd; }

catch (Exception se) { throw new Exception("Error Occurred in AuditAdapter.getXMLDocumentFromXMLTemplate()", se); } }

Manikant Thakur