c# client application can't consume tomtom connect webservice - c#

I have to write a windows application in c# which application is able to consume said webservice.
I am using VS2010 with .Net 4
I added the service reference and the code compiles without any error, but when i run it i get a ProtocolException with the text:
The content type "multipart/related; type="application/xop+xml";
boundary="----=_Part_0_159582014.1283501395804";
start="";
start-info="application/soap+xml"" of the response does not match the
binding (application/soap+xml; charset=utf-8)
When i try it with a VB sample provided by the developers of the webservice everything works fine.
Im totally lost here, googled since yesterday, came up with nothing... Anyone knows whats the problem there?

Ok finally figured it out.
You need to manually edit the app.config file of your application and change all occurences of "textMessageEncoding" to "motmMessageEncoding" that will do the trick

no motmMessageEncoding -> mtomMessageEncoding
you need to make sure that your application supports MTOM. This
requires a change to your app.config. More details can be found here:
http://www.tomtomwork.com/en/webfleet/connect/blog.xml - scroll down
to the section "Updated Visual Basic example now uses SOAP, too"

Try adding a Web Reference rather than a Service Reference and see if that makes any difference. When you select Add Service Reference, click "Advanced..." then "Add Web Reference..." to bring up the old style reference screen.

Related

Adding a Web Service for ReportExecution2005 - Resource cannot be found C#

I'm trying to add the ReportExecution2005 Web Service into my project to allow me to execute reports from within my program.
We do this in other programs that are written in VB.net however, these programs have a namespace added for ReportingService that's around 3000 lines of code as the company has always struggled with adding the ReportExecution web service. Before I begin converting this code from VB.net to C# I thought I'd try again in getting it working the proper way.
I'm currently going to the Add Web Reference page, and putting the following:
http://reportserver/Reports/ReportExecution2005.asmx
This is returning a 404 error saying the resource can't be found. I've checked the URL over and over and got colleagues too. So I'm not really sure what else the issue could be.
Is there something that needs adding onto our report server for me to be able to add the web reference?
If anyone has had this issue before how did you solve it?
Any tips appreciated.

Consuming multiple WCF services from a single client

I have hosted two WCF services using a console application, one on port 8080 and the other at port 8090. I am able to create object for the first service named AccountManagementService but not for the other service named UserRegistrationService.
Snapshot below shows that two services have been added.
The second service doesn't show up in intellisense at all.
The complete details of the service used can be found at the following link(this is also a question asked by me):
Hosting two WCF services using a single console app
I have tried multiple times deleting and creating new service but nothing seems to be working. Please suggest.
based on the image, it should be there. open the reference.cs file for the service that is not showing up in IntelliSense and check the namespace. Then Try creating the reference using the full name. to get to the reference.cs file, click on Show all files in solution explorer as shown below
for example, if in reference.cs, you see the namespace WWWCF.UserRegistration as foo.bar.WWWCF.UserRegistration, then create instance using
foo.bar.WWWCF.UserRegistration ref = new foo.bar.WWWCF.UserRegistration ();
Found the solution. Not sure I understand the reason, though. But the following link has answers to my issue and has solved it.
Empty Reference.cs file issue solved

Windows Store App Webservice

I have made my first webservice but now I'am having trouble connecting to it.
In my visual studio I did add "Service Reference" and linked my site url to it.
Here on the picture: http://prntscr.com/3108bk , you can see under Service References my web server + you can see clearly that it has an operation
My problem is now that I cannot use it in my code.
The error I have is: are you missing a reference but I added it into my references!
http://prntscr.com/3108sm
If you have any idea how I can use this in my code, please help me!
I think that I found my error, I am trying to connect to my server but I have to make a client first.
But now I have to problem that I have no clue how to make that client
https://stackoverflow.com/questions/22426532/how-to-make-client-web-service

Error when trying to add a Service Reference

I´m trying to create a client in C# to a web service which (I suppose) is written in Java. It´s my first time trying to write a client, so I´m following the instructions on MSDN, but I´m stuck on a problem with Add Reference. When I open the Add Service Reference dialog and add the URL, an error occurs:
There was an error downloading 'http://geoportal.cuzk.cz/WCTService/WCTService.svc'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://geoportal.cuzk.cz/WCTService/WCTService.svc'.
There was no endpoint listening at http://geoportal.cuzk.cz/WCTService/WCTService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
What should my next step be? I don´t know what I should do with this!
(It is a coordinates-transformation service from the Czech Republic.)
For more information:
Property services (GetCapabilities)
http://geoportal.cuzk.cz/WCTService/WCTService.svc/get?
Localization services:
http://geoportal.cuzk.cz/WCTService/WCTService.svc/get?request=GetCapabilities&service=WCTS
I was facing a similar situation in which I had created a WCF Service (Employee.svc) and later changed the named to EmployeeService.svc. WCF project compiled just fine but when I was trying to add service reference from by UI Client, I was getting following error:
Metadata contains a reference that cannot be resolved: 'http://localhost:2278/EmployeeService.svc?wsdl'.
The document format is not recognized (the content type is 'text/html; charset=UTF-8').
Metadata contains a reference that cannot be resolved: 'http://localhost:2278/EmployeeService.svc'.
There was no endpoint listening at 'http://localhost:2278/EmployeeService.svc' that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
I resolved it by replacing the correct service class name everywhere. In my case, it should have been EmployeeService and NOT employee. The left out place was in the markup code of svc file:
<%# ServiceHost Language="C#" Debug="true" Service="WCFServiceHost.**Employee**" CodeBehind="EmployeeService.svc.cs" %>
Changed it to
<%# ServiceHost Language="C#" Debug="true" Service="WCFServiceHost.**EmployeeService**" CodeBehind="EmployeeService.svc.cs" %>
And it started working again!!! Dont forget to build your WCF project after changing the service name.
I tried browsing to http://geoportal.cuzk.cz/WCTService/WCTService.svc?wsdl. It looks like this service is not exposing metadata.
I did a bit of googling on OpenGIS, and I think you need to have a look at this article:
OpenGIS with .NET
You won't be able to just add a service reference and go. It looks like you need to craft a concrete WSDL.
There may be a client-side library you can use / customize to assist with integration. Have a look at Stack Overflow question Using MySQL GeoSpatial data types in .NET.
I know this is an old thread and has already been resolved, but I just finished troubleshooting this exact issue, and none of the resolutions presented here worked for me. Wanted to share my resolution in case anyone else runs into this thread with a similar issue.
My ENTIRE issue stemmed from a bad Refactor->Rename operation. I recently purchased Resharper for my dev team and Resharper did not like the name of our service implementation name. We had named it "WCFAccess" and Resharper wanted the name "WcfAccess". I had just published an update, had the release safely isolated in its own release branch in git, and figured this was a good time to perform a rename on the develop branch and shut Resharper up about the naming. I used Refactor->Rename to change the name of the file to match the naming convention we had defined in the Resharper configuration. The rename operation completed, the solution compiled and ran, time goes on and the WCF rename was forgotten.
Fast forward a couple weeks, and its time to deploy out web services to the test environment for regression testing. The solution compiled successfully, published successfully, then gave me the EXACT error that the OP posted. What I ended up finding out is that the Rename operation from weeks ago ONLY UPDATED SOURCE CODE REFERENCES to the old name and did not rename MARKUP. When I navigated out to our web server where the service was published to and double clicked on the .svc file, it opened the markup in Visual Studio and I noticed that the character casing of the CodeBehind="ServiceNameHere.svc.vb" was inconstant with the new naming convention. Updating the markup and web.config files to reference the correct character casing resolved my issue.
I hope this helps someone. It was incredibly frustrating to troubleshoot
(Please don't hate me for using VB.Net, I inherited this application) :-)
Is the service definitely up and running before you try to add a service reference? If it exposes meta data, does it have a service behaviour or equivalent configured? Have you configured your firewall correctly?
While adding service reference to the client application, metadata is not accessible from service to client application. hence The remote server returned an error: (404) Not Found. Actually we can host the WCF service as follows:
Self hosting(console application)
IIS Hosting
WAS Hosting
window service hosting.
if you are using self hosting then you need to host the service in console application and run the service(run the console application) and then add the service reference to the client application, then metadata would be exchange. If service is not running then while adding service reference to the client application then 404 not found error would be getting. Same process would follow for all the hosting type. first run the service then add service reference.
I had the same problem happen to me earlier today. The webservice was running fine on local host but for some reason, I was having a 400 when trying to add the service reference in another project.
My error was caused by setting the [DataMember] annotation instead of the [EnumMember] annotation on an enum of the service. Changing it solved my issue.
The webservices doesn't run.
If you don't have access to the server where this service run, you're blocked.
Otherwise, you need to check if the server run, etc. As I don't know how the Java webservice is run, I can't help you further.

Using a WebService From Another Project in my own project in C#

Hello i'm trying to add a webservice to my project, and that web service is from another project i have open. IIS is set up and everything works good with the webService.
Ok so on first image ,im using the webservice in the same project i have it created and it works fine
http://img215.imageshack.us/img215/4605/55347669.jpg
On second image i add the webreference and it is added succesfully . Thing is i dont know how to access it ( the HelloWorld function that returns a string which i want to set up to be text for the label )
http://img846.imageshack.us/img846/4922/19350256.jpg
The error i get at the second image says
" BankarskiUslugi is a namespace but it is used as type."
So i would appreciate any help if someone tells me how can i 'call' the webservice in my proect.
Thanks a lot in advance !
When you added the web service reference, it should have shown a namespace for the web service you were referencing; you need to add something like:
using YourWebServiceNamespace;
And then you should be able to instantiate it and call the methods as you are trying to do on the second image.
Alternatively, you can use WCF Test Client (WcfTestClient.exe) as far as testing is concern.
See How to Consume a Web Service.

Categories

Resources