rhawk
rhawk

Reputation: 71

ServiceStack - generate ASP.NET webservice -reference issue

I am using the very excellent servicestack libaries and trying to generate a ASP.NET web-service reference (old style not WCF) from within VS2010 across my servicestack WSDL - Soap11. To nicely wrap the service WSDL.

The DTO's are in a seperate assembly/namespace (My.WS.DTO) from the AppHost/services and are following the request/response naming convention.. when I try to generate the reference through visual studio I get the following error in VS.

Custom tool error: Unable to import WebService/Schema. Unable to import binding 'BasicHttpBinding_ISyncReply' from namespace 'http://schemas.servicestack.net/types'. Unable to import operation 'GetMyDetails'. The element 'http://schemas.servicestack.net/types:GetMyDetails' is missing.

NOTE: GetMyDetails is just the first service that appears in the list - so I dont believe this is the problem.

I have tried adding the assembly namespace in the AppHost file using EndpointHostConfig.Instance.WsdlServiceNamespace = "My.WS.DTO"; and this just causes the same generation error (as above) but with 'My.WS.DTO' instead of 'http://schemas.servicestack.net/types'.

I assume it is perhaps some sort of referencing problem but any guidance as to what I might be doing wrong would be great. cheers

Upvotes: 6

Views: 790

Answers (3)

James Eby
James Eby

Reputation: 1784

I know this is an old question, but I had to add SOAP support for a 3rd party that refused to support REST very recently to my ServiceStack implementation so it could still be relevant to other people still having this issue.

I had the same issue you were having:

Unable to import binding 'BasicHttpBinding_ISyncReply'...

And like mickfold previously answered I needed to add [DataContract] and [DataMember] to my class definitions and their properties.

But I also had to add the following to my AssemblyInfo.cs file before the error went away for me:

[assembly: ContractNamespace("http://schemas.servicestack.net/types", ClrNamespace = "My Type Namespace")]

I assume that you will need one of these lines for every single namespace where you have a type declared, which based upon the original question above would be My.WS.DTO.

Upvotes: 1

Shane van Wyk
Shane van Wyk

Reputation: 1900

Have a look at using [DataContract (Namespace = "YOUR NAMESPACE")] on top of your DTO's. This is how my objects are referenced.

[DataContract(Namespace = "My.WS.DTO")]
public class Account{
}

I also use this in my service model. [System.ServiceModel.ServiceContract()] and [System.ServiceModel.OperationContract()]

[System.ServiceModel.ServiceContract()]
public class SendGetAccountResponseService : IService<SendGetAccountNotification>
{
#region IService implementation
[System.ServiceModel.OperationContract()]
public object Execute (SendGetAccountNotification request)
{
    Console.WriteLine ("Reached");
    return null;
}
#endregion
}

Hope this helps / solves your problem.

Upvotes: 1

mickfold
mickfold

Reputation: 2003

I don't know if this is still an issue for you but I had a similar problem and found that I had not decorated one of my DTOs with [DataContract] and [DataMember] attributes, as described on the SOAP Support wiki page. Once you have added these to your DTO it will be declared in the type section of the WSDL.

Upvotes: 3

Related Questions