1

I'm having trouble understanding how to consume an existing ServiceStack based web service (https://cert.web.transaction.transactionexpress.com/TransFirst.Transaction.Web/api/). I am using a standard vstudio .net 4.6 aspnet website c# form.

I tried adding the base service uri as a service reference to my existing project (Website > Add Service Reference > URI) but on building my solution I receive error: [Error: failed to generate code for the service reference. Cannot import wsdl:portType...].

I would like to think that I can interact with this service without manually building object definitions, so I must be missing a step.

Two questions:
1. Has anyone else worked with this particular service? Or can you suggest how to generate object definitions from this service? 2. Am I incorrectly assuming that generating the object definitions will give me full VStudio intellisense on my httpclient?

1 Answer 1

3

Since this is a ServiceStack Web Service you can use C# Add ServiceStack Reference to generate a Typed API in C# which you can use with ServiceStack's C# Service Clients.

The BaseUrl for this Service is:

https://cert.web.transaction.transactionexpress.com/TransFirst.Transaction.Web/api/

So if you install ServiceStack VS from VS.NET Extension gallery:

enter image description here

You can create a Typed C# API by clicking on Add ServiceStack Reference on your project:

enter image description here

Then you can use the Typed DTOs with ServiceStack's generic Service Clients, e.g:

var baseUrl = "https://cert.web.transaction.transactionexpress.com/TransFirst.Transaction.Web/api/";
var client = new JsonServiceClient(baseUrl);
var response = client.Post(new CreateCustomReport { ... });
Sign up to request clarification or add additional context in comments.

6 Comments

OK thanks for the quick response. I add the SS Reference but the generated class has a series of errors beginning with "Type or namespace name 'DataContractAttribute' could not be found (are you missing...)", "'DataContract' could not be found ... etc.
OK, maybe I'm getting closer to the question I should be asking...VS (2015/2017) doesn't have a menu option to add an SS Reference in an existing aspnet site. I tried to work around that by adding a separate SS project to my existing solution. Having both projects in one solution causes VS to indicate errors with the DataContract in the generated class file. So - is there any way to add a SS Reference to an existing aspnet website?
@MTAdmin My answer shows how to Add a ServiceStack Reference to an existing project. I don't know what your error you're getting but it sounds like a dependency conflict. You can add a reference without a UI by including TransFirst.Transaction.Web/api/types/csharp source file in your project and manually adding a reference to ServiceStack.Client NuGet package.
Adding the static types source file answers my question. I suppose this introduces the possibility of future source changes breaking my offline types but I can live with this for now. Thanks for your help!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.