Note that there are some explanatory texts on larger screens.

plurals
  1. POVisual Studio referencing a ServiceStack SOAP method
    primarykey
    data
    text
    <p>I have a simple API setup using ServiceStack. I use the following code to get it running:</p> <pre><code>namespace TheGuest.Test { [DataContract] [Description("A sample web service.")] public class Greet { [DataMember] public string Name { get; set; } } [DataContract] public class GreetResponse { [DataMember] public string Result { get; set; } } /// &lt;summary&gt; /// An example of a very basic web service. /// &lt;/summary&gt; public class GreetService : IService&lt;Greet&gt; { public object Execute(Greet request) { return new GreetResponse { Result = "Hello " + request.Name }; } } public static class Constants { public const string DefaultNamespaceV1 = "http://my/custom/namespace"; } public class MyAppHost : AppHostBase { // Tell Service Stack the name of your application and where to find your web services. public MyAppHost() : base("My Web Services", typeof(GreetService).Assembly) { } public override void Configure(Container container) { SetConfig(new EndpointHostConfig { WsdlServiceNamespace = Constants.DefaultNamespaceV1 }); // Register user-defined REST-ful URLs. Routes .Add&lt;Greet&gt;("/hello") .Add&lt;Greet&gt;("/hello/{Name}") .Add&lt;Greet&gt;("/hello/{Name*}"); } } public class MvcApplication : HttpApplication { protected void Application_Start() { new MyAppHost().Init(); } } } </code></pre> <p>And adding the following line to the AssemblyInfo.cs:</p> <pre><code>[assembly: ContractNamespace("http://my/custom/namespace", ClrNamespace = "TheGuest.Test")] </code></pre> <p>It will generate the following WSDL:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;wsdl:definitions name="Soap12" targetNamespace="http://my/custom/namespace" xmlns:svc="http://my/custom/namespace" xmlns:tns="http://my/custom/namespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"&gt; &lt;wsdl:types&gt; &lt;xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="anyType" nillable="true" type="xs:anyType" /&gt; &lt;xs:element name="anyURI" nillable="true" type="xs:anyURI" /&gt; &lt;xs:element name="base64Binary" nillable="true" type="xs:base64Binary" /&gt; &lt;xs:element name="boolean" nillable="true" type="xs:boolean" /&gt; &lt;xs:element name="byte" nillable="true" type="xs:byte" /&gt; &lt;xs:element name="dateTime" nillable="true" type="xs:dateTime" /&gt; &lt;xs:element name="decimal" nillable="true" type="xs:decimal" /&gt; &lt;xs:element name="double" nillable="true" type="xs:double" /&gt; &lt;xs:element name="float" nillable="true" type="xs:float" /&gt; &lt;xs:element name="int" nillable="true" type="xs:int" /&gt; &lt;xs:element name="long" nillable="true" type="xs:long" /&gt; &lt;xs:element name="QName" nillable="true" type="xs:QName" /&gt; &lt;xs:element name="short" nillable="true" type="xs:short" /&gt; &lt;xs:element name="string" nillable="true" type="xs:string" /&gt; &lt;xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" /&gt; &lt;xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" /&gt; &lt;xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" /&gt; &lt;xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" /&gt; &lt;xs:element name="char" nillable="true" type="tns:char" /&gt; &lt;xs:simpleType name="char"&gt; &lt;xs:restriction base="xs:int" /&gt; &lt;/xs:simpleType&gt; &lt;xs:element name="duration" nillable="true" type="tns:duration" /&gt; &lt;xs:simpleType name="duration"&gt; &lt;xs:restriction base="xs:duration"&gt; &lt;xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" /&gt; &lt;xs:minInclusive value="-P10675199DT2H48M5.4775808S" /&gt; &lt;xs:maxInclusive value="P10675199DT2H48M5.4775807S" /&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;xs:element name="guid" nillable="true" type="tns:guid" /&gt; &lt;xs:simpleType name="guid"&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" /&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;xs:attribute name="FactoryType" type="xs:QName" /&gt; &lt;xs:attribute name="Id" type="xs:ID" /&gt; &lt;xs:attribute name="Ref" type="xs:IDREF" /&gt; &lt;/xs:schema&gt; &lt;xs:schema xmlns:tns="http://my/custom/namespace" elementFormDefault="qualified" targetNamespace="http://my/custom/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:complexType name="Greet"&gt; &lt;xs:sequence&gt; &lt;xs:element minOccurs="0" name="Name" nillable="true" type="xs:string" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:element name="Greet" nillable="true" type="tns:Greet" /&gt; &lt;/xs:schema&gt; &lt;/wsdl:types&gt; &lt;wsdl:message name="GreetIn"&gt; &lt;wsdl:part name="parameters" element="tns:Greet" /&gt; &lt;/wsdl:message&gt; &lt;wsdl:portType name="ISyncReply"&gt; &lt;/wsdl:portType&gt; &lt;wsdl:portType name="IOneWay"&gt; &lt;wsdl:operation name="Greet"&gt; &lt;wsdl:input message="svc:GreetIn" /&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:portType&gt; &lt;wsdl:binding name="WSHttpBinding_ISyncReply" type="svc:ISyncReply"&gt; &lt;soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /&gt; &lt;/wsdl:binding&gt; &lt;wsdl:binding name="WSHttpBinding_IOneWay" type="svc:IOneWay"&gt; &lt;soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /&gt; &lt;wsdl:operation name="Greet"&gt; &lt;soap:operation soapAction="http://schemas.servicestack.net/types/Greet" style="document" /&gt; &lt;wsdl:input&gt; &lt;soap:body use="literal" /&gt; &lt;/wsdl:input&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:binding&gt; &lt;wsdl:service name="SyncReply"&gt; &lt;wsdl:port name="WSHttpBinding_ISyncReply" binding="svc:WSHttpBinding_ISyncReply"&gt; &lt;soap:address location="http://localhost:50472/test/soap12" /&gt; &lt;/wsdl:port&gt; &lt;/wsdl:service&gt; &lt;wsdl:service name="AsyncOneWay"&gt; &lt;wsdl:port name="WSHttpBinding_IOneWay" binding="svc:WSHttpBinding_IOneWay"&gt; &lt;soap:address location="http://localhost:50472/test/soap12" /&gt; &lt;/wsdl:port&gt; &lt;/wsdl:service&gt; &lt;/wsdl:definitions&gt; </code></pre> <p>When I add this service via Visual Studio 2010, I get 2 clients. One is called "SyncReplyClient" which has no methods I can call and the other is called "OneWayClient" with a "Greet" method. But as the names imply, I would like to use the SyncReplyClient since I need the response. </p> <p>How do I achieve this?</p> <p>On a side note, the OneWayClient throws an ProtocolException with the following message: "The one-way operation returned a non-null message with Action=''." which does not bother me as much since I don't want to use the OneWayClient but it's strange none the less.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload