how to consume web service from desktop c# app?

Lukasz

I'm trying to consume a HTTP web service returning XML generated by a DataContractSerializer in a C# Desktop application. The link to the service doesn't have any aspx or svc extention, and the parameters are expected in the link.

https://sourcesite.com/api/external/v1/Snapshot?isConfirmed={isConfirmed}&sinceDate={sinceDate}&pageNumber={pageNumber}&recordsPerPage={recordsPerPage}

It works when I use it in a browser (after providing proper parameter values). When run for the first time it asked me my credentials which it accepted and didn't ask again, even after the browser restart.

I tried adding a web reference (using VS2013), using url without the parameters but I'm getting errors:

The remote server returned an unexpected response: (405) Method Not Allowed.

If I add hardcoded parameters, I get:

The document at the url https://sourcesite.com/api/external/v1/Snapshot?isConfirmed=True was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'XML Schema' is 'Data at the root level is invalid. Line 1, position 1.'. - Report from 'DISCO Document' is 'Data at the root level is invalid. Line 1, position 1.'. - Report from 'WSDL Document' is 'There is an error in XML document (1, 1).'. - Data at the root level is invalid. Line 1, position 1. Metadata contains a reference that cannot be resolved: 'https://sourcesite.com/api/external/v1/Snapshot?isConfirmed=True'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed. If the service is defined in the current solution, try building the solution and adding the service reference again.

Is the service incorrectly configured, or am I missing something? Perhaps there's a different way to connect to this service form the code?

John Saunders

"Add Service Reference" and "Add Web Reference" are for SOAP web services.

You'll have to use the WebClient class and "do it yourself".

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to Consume an RPC-Style Web Service with a WCF Service Reference?

From Dev

How to build RESTful web service API for user login using C# to consume on my iPhone app

From Dev

How to consume third party https wsdl web service in c#

From Dev

Trying to consume Web Service class

From Dev

How to consume a JSON web service in Java

From Dev

Trying to consume a C# web service in VB.NET

From Dev

Mule: how to consume a service from a remote client

From Dev

How to encrypt communication between a desktop app and a REST-based web service?

From Dev

AngularJS: consume web service from Wikipedia API

From Dev

How to consume Rest Web service in c#

From Dev

How to consume duplex wcf service in Windows Universal App

From Dev

how to consume a Restful Web Service (Restful API) in Java

From Dev

c# - Consume soap web service with Xamarin.droid

From Dev

Phonegap app - How to get images from Json Web Service Response?

From Dev

Unable to consume web service

From Dev

Consume web service returning list

From Dev

Mule: how to consume a service from a remote client

From Dev

How to consume wsdl web service by using a certificate in Windows Phone 8?

From Dev

Cannot consume WCF service in desktop application

From Dev

How do I consume this xml web service in c#?

From Dev

How to encrypt communication between a desktop app and a REST-based web service?

From Dev

How to consume a .net web service from a remote server with javascript

From Dev

consume rest web service in TextBlocks

From Dev

How to consume a rest web service in phonegap for android?

From Dev

Moving Balsamiq Mockups from Web to Desktop App

From Dev

How to consume liferay web service written in liferay from java client?

From Dev

how to consume the json web service in objective c?

From Dev

Httpclient consume web api via console app C#

From Dev

How to consume a web service with headers C #?

Related Related

  1. 1

    How to Consume an RPC-Style Web Service with a WCF Service Reference?

  2. 2

    How to build RESTful web service API for user login using C# to consume on my iPhone app

  3. 3

    How to consume third party https wsdl web service in c#

  4. 4

    Trying to consume Web Service class

  5. 5

    How to consume a JSON web service in Java

  6. 6

    Trying to consume a C# web service in VB.NET

  7. 7

    Mule: how to consume a service from a remote client

  8. 8

    How to encrypt communication between a desktop app and a REST-based web service?

  9. 9

    AngularJS: consume web service from Wikipedia API

  10. 10

    How to consume Rest Web service in c#

  11. 11

    How to consume duplex wcf service in Windows Universal App

  12. 12

    how to consume a Restful Web Service (Restful API) in Java

  13. 13

    c# - Consume soap web service with Xamarin.droid

  14. 14

    Phonegap app - How to get images from Json Web Service Response?

  15. 15

    Unable to consume web service

  16. 16

    Consume web service returning list

  17. 17

    Mule: how to consume a service from a remote client

  18. 18

    How to consume wsdl web service by using a certificate in Windows Phone 8?

  19. 19

    Cannot consume WCF service in desktop application

  20. 20

    How do I consume this xml web service in c#?

  21. 21

    How to encrypt communication between a desktop app and a REST-based web service?

  22. 22

    How to consume a .net web service from a remote server with javascript

  23. 23

    consume rest web service in TextBlocks

  24. 24

    How to consume a rest web service in phonegap for android?

  25. 25

    Moving Balsamiq Mockups from Web to Desktop App

  26. 26

    How to consume liferay web service written in liferay from java client?

  27. 27

    how to consume the json web service in objective c?

  28. 28

    Httpclient consume web api via console app C#

  29. 29

    How to consume a web service with headers C #?

HotTag

Archive