0

After spending a lot of time on research, trying it with various approaches, I've decided to ask a question here, as I'm out of ideas now. What I want to achieve is call a sendDocument operation on a webservice, which is located right here:

https://test-bramka.edeklaracje.gov.pl/uslugi/dokumenty?wsdl

I've added a service reference to my VS project successfully. Then I've tried to do it as everyone was suggesting through the Internet:

eDeklaracjeTest client = new eDeklaracjeTest();
client.sendDocument(b1);

But VS keeps on telling me, that eDeklaracjeTest is a namespace, but is used like a type. When declaring it like:

var client = new eDeklaracjeTest.sendDocument();

It sounds right and afterwards I can do:

client.document = b1;

But that does not call sendDocument method. What is wrong with my call? How to call sendDocument correctly so I can confirm, that my request was received and how could I receive an answer?

UPDATE After some hours of research and one question to colleague from work, I've finally received an answer (thanks to CodeCaster, as his help was also really helpful). Correct code for that WebService looks like:

eDeklaracjeTest.sendDocumentResponse resp;
byte[] b1 = null;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var client = new eDeklaracjeTest.GateServicePortTypeClient("GateServiceSOAP11port");
var documentToSend = new eDeklaracjeTest.sendDocument();
documentToSend.document = b1;
client.Open();
resp = client.sendDocument(documentToSend);

Thanks to everyone, who tried to help me with that issue.

Mariusz Mizgier
  • 527
  • 2
  • 13
  • When adding a service reference, did you enter the namespace `eDeklaracjeTest`? Then you need a `new eDeklaracjeTest.{SomeServiceName}Client()`. – CodeCaster Sep 19 '16 at 20:38
  • Yes, namespace was eDeklaracjeTest. However, adding it as you suggested - eDeklaracjeTest client = new eDeklaracjeTest{sendDocument}.Client(); results in The name 'sendDocument' does not exist in the current context error. – Mariusz Mizgier Sep 19 '16 at 20:43
  • Yeah so open up the Object Browser and check what names _do_ exist in that namespace. – CodeCaster Sep 19 '16 at 20:46
  • List of names are as follow (would like to add it as a list, but I hope that easier to read would be from this screenshot). http://i64.tinypic.com/r2s3tt.png – Mariusz Mizgier Sep 19 '16 at 20:54
  • You need the class ending in "Client". – CodeCaster Sep 19 '16 at 20:55
  • No such class exists. When writting this code I was also looking at http://stackoverflow.com/questions/3100458/soap-client-in-net-references-or-examples - however, when you add as a service reference the service provided above (nothing to do about it, as it's our government service), you do not have method to call from sendDocument. – Mariusz Mizgier Sep 19 '16 at 21:16
  • There is, it's called GateServicePortTypeClient. – CodeCaster Sep 19 '16 at 21:18
  • Woah, that works almost like a charm, but still I was not able to get a response. I'm with that code now: var client = new GateServicePortTypeClient("GateServiceSOAP11port"); var documentToSend = new sendDocument(); documentToSend.document = b1; client.Open(); client.sendDocument(documentToSend); But still don't really know how to ask for an answer here... – Mariusz Mizgier Sep 19 '16 at 21:36
  • Are you using soap client? – Vijunav Vastivch Sep 20 '16 at 00:41

1 Answers1

0

Yes cause you are missing the parenthesis () while instantiating the service proxy class. It should be

var client = new eDeklaracjeTest().sendDocument(); 
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • When defined as you suggested, error like on screenshot http://i63.tinypic.com/zkrec0.png occurs. – Mariusz Mizgier Sep 19 '16 at 20:23
  • @MariuszMizgier, post the error text instead of pic and moreover your pic doesn't show anything. Also post some code – Rahul Sep 19 '16 at 20:25
  • I've tried to do it with your suggestion: var client = new eDeklaracjeTest().sendDocument(); client.document = b1; But VS 2015 keeps on saying that eDeklaracjeTest is a namespace but is used as a type. If you could guide me, what more should I provide (I've just added a Service Reference to a VS project), I would be thankful. b1 definition is - byte[] b1 = System.Text.Encoding.UTF8.GetBytes(xmlSigned); – Mariusz Mizgier Sep 19 '16 at 20:26