0

I am stuck at this: I need to write Client for Web Service. As Input I have 1) WSDL file WebServ.wsdl. This service implement a lot of Methods. I need just one - GetInvoice 2) Also I know that here there is a Two-Factor Authentication and I need to pass into Web Service Token as Header for SOAP: Header Name: X-SPP-API-Token

and I know that it should be - HTTP post.

The question is - how can I combine WSDL with HTTP POST Header ? I even don't know how to start it...

I have something like that:

//----Request Set-Up
            req.Method = "POST";
            req.ContentType = "text/xml";
            req.Host = "api.spp.org";
            req.ContentLength = postBytes.Length;
            req.ProtocolVersion = HttpVersion.Version11;
            req.ClientCertificates.Add(certificates[0]);
            req.Headers["X-SPP-API-Token"] = token;
            req.KeepAlive = true;            

            //-----POST Request
            Stream postStream = req.GetRequestStream();
            postStream.Write(postBytes, 0, postBytes.Length);
            postStream.Flush();
            postStream.Close();
  • Having a wsdl usually means you are going to generate a client with wsdl.exe. You could use a WebRequest but it's more work. The client will seem like regular method calls on an object. – Crowcoder Jul 25 '18 at 17:14
  • Can i do with help of wsdl.exe *.CS files which i can use in my program ? And how should I connect MainProgram and new generated files ? Something like USING.... –  Jul 25 '18 at 17:36
  • Check [this out](https://stackoverflow.com/questions/12710281/how-to-generate-service-reference-with-only-physical-wsdl-file) – Crowcoder Jul 25 '18 at 17:40
  • Ok but how it's possible to pass Header into WSDL in the Client ? What should I use for this ? –  Jul 26 '18 at 00:01
  • The generated client should take care of all the parameters you need to send. If it doesn't then it's implementation is flawed. – Crowcoder Jul 26 '18 at 00:36

0 Answers0