-1

I searched many examples of how to consume webservices methods with C#, but all of them say to right click and add a service reference and type the address.

However I dont know why, but the webserver wich I am trying to connect does not work with this...

Here the address https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl

Can someone help me how could I interact with this specific webservice?

Grant Thomas
  • 44,454
  • 10
  • 85
  • 129
  • 6
    Looks OK when you click on the link. Are you getting an error message? What does it say? – Robert Harvey Jun 12 '13 at 19:48
  • Strange, when adding a service reference for that url, VS.NET doesn't seem to be able to generate the necessary code. – Frederik Gheysels Jun 12 '13 at 19:55
  • @RobertHarvey: I've never had definitive success looking at a ?wsdl and detecting issues--You must be some kind of WCF prodigy. ;p – Brad Christie Jun 12 '13 at 19:58
  • @BradChristie: The question says "it doesn't work." Unfortunately I left my psychic debugger at home. :) wcfTestClient looks like a cool tool, though. – Robert Harvey Jun 12 '13 at 20:16
  • Ending with just "it doesn't work" always makes a bad question. – H H Jun 12 '13 at 20:26
  • tried to add as WebServer and got: There was an error downloading 'https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl'. The underlying connection was closed: An unexpected error occurred on a send. Received an unexpected EOF or 0 bytes from the transport stream. There was an error downloading 'https://bauru.sigiss.com.br/baur – Igor Campos Jun 13 '13 at 11:40
  • @HenkHolterman: sorry... Im kindda new in this thing – Igor Campos Jun 13 '13 at 12:12
  • Your question is only 'new' for a few minutes. After that views drop. It is in your own interest not to leave the potential answerers guessing for anything. – H H Jun 13 '13 at 12:15

3 Answers3

3

Using the WcfTestClient1 shows an error (that is probably the one you're running in to on an import):

Error: Cannot import wsdl:portTypeDetail: The ' ' character, hexadecimal value 0x20, cannot be included in a name.Parameter name: nameXPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sigiss_ws']/wsdl:portType[@name='WebService SigISSPortType']Error: Cannot import wsdl:bindingDetail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='urn:sigiss_ws']/wsdl:portType[@name='WebService SigISSPortType']XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sigiss_ws']/wsdl:binding[@name='WebService SigISSBinding']Error: Cannot import wsdl:portDetail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='urn:sigiss_ws']/wsdl:binding[@name='WebService SigISSBinding']XPath to Error Source: //wsdl:definitions[@targetNamespace='urn:sigiss_ws']/wsdl:service[@name='WebService SigISS']/wsdl:port[@name='WebService SigISSPort']Warning: No code was generated.If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servicesor because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.

I don't know enough about the service, but you may take a look at Can I create an element with forward slash as part of the name and find it's probably an attribute being used to decorate a property (which has a space in it).

1 WcftestClient can usually be found in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\

Community
  • 1
  • 1
Brad Christie
  • 100,477
  • 16
  • 156
  • 200
  • Good catch. I got no error from "Add Service Reference", but it didn't produce any code, either. – John Saunders Jun 12 '13 at 19:55
  • @JohnSaunders: Luckily, through experience, I've found a few extra methods to detect WCF errors. Though I'm not sure why I need them; I always code things _perfectly_. :grin: – Brad Christie Jun 12 '13 at 19:56
  • @BradChristie: I got another error but it is too long to post here I'll put in parts: URI: https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl Metadata contains a reference that cannot be resolved: 'https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl'. An error occurred while making the HTTP request to https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. – Igor Campos Jun 13 '13 at 11:48
  • @BradChristie part 2: The underlying connection was closed: An unexpected error occurred on a send.Received an unexpected EOF or 0 bytes from the transport stream.HTTP GET Error URI: https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl There was an error downloading 'https://bauru.sigiss.com.br/bauru/ws/sigiss_ws.php?wsdl'. The underlying connection was closed: An unexpected error occurred on a send. Received an unexpected EOF or 0 bytes from the transport stream. – Igor Campos Jun 13 '13 at 11:50
  • @IgorCampos: have a look at http://stackoverflow.com/questions/4660480/wcf-metadata-contains-a-reference-that-cannot-be-resolved & http://stackoverflow.com/questions/2013880/wcf-error-this-could-be-due-to-the-fact-that-the-server-certificate-is-not-conf. Also, do you own this service? You may want to enable tracing on the server and use the SvcTraceViewer to determine (more finitely) what's going on. – Brad Christie Jun 13 '13 at 12:27
  • I dont own this server... But I need to make it work with VS, I know some people did get it working with Delphi... – Igor Campos Jun 13 '13 at 14:00
  • What should I exactly say to the people that owns the server?? – Igor Campos Jun 13 '13 at 14:32
  • @IgorCampos: not sure as it's tough to debug from the outside. I would just either ask them how you can use the service with C#, or direct them to the WcfTestClient/wsdl.exe applications and show them the problems you're running in to (and pass along the same errors to them as you've provided me). – Brad Christie Jun 13 '13 at 15:12
  • I see, I am afraid they will say: "everybody else (the ones who use Delphi) can connect and interact fine with our WS why cant you? Thats your problem" But I'll try. Thx a lot for all the help – Igor Campos Jun 13 '13 at 15:17
  • @IgorCampos: that doesn't mean those using delphi didn't run in to trouble and just worked around it, too. ;-) either way, good luck and it's not just you having a problem establishing a connection. – Brad Christie Jun 13 '13 at 15:21
2

If for whatever reason you can't get to it (e.g. a proxy server is used where you're working) then simply go to the WSDL in your browser, save the page as an XML file on disk, and when adding a service reference again don't put in the web URL, put the path to it on disk (e.g. C:\temp\wsdl.xml).

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
2

Finally I got someone who had the exaclty same problem as I did! He said to do the following:

For Windows Vista, Windows 7 e Server 2008: Start>Run Regedit HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/SecurityProviders/Schannel/Protocols

            Right Click on  Protocols -> New -> Key
            Name: TLS 1.0

            Right Click on the new key -> New -> Key
            Name: Client

            Select the created folder (Client), right click New -> Value DWORD
            Name: Enabled

After that just add the reference to your project. To avoid happening the same in your app users, force the SSL use before instanciate the webservice:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;