SoapCore icon indicating copy to clipboard operation
SoapCore copied to clipboard

Include out parameters in wsdl

Open cubidobusinesssolutions opened this issue 9 years ago • 9 comments

Hi,

out parameters are missing in created wsdl. See sample SampleService.VoidMethod(out var stringValue). For testing, I created a .NET Framework 4.6.1 client project using ServiceReference to create a client from wsdl. There, the out parameter is missing, see Client461.zip.

Best regards, Markus

cubidobusinesssolutions avatar Nov 30 '17 08:11 cubidobusinesssolutions

Does SOAP support .NET out parameters at all? I was under the impression that everything you want to return from a SOAP call must be in the returned object.

MFinkBK avatar Dec 12 '17 09:12 MFinkBK

@MFinkBK Yes it does! At least the non-wcf SOAP client/server. The following snippet should help generating wsdl. Note that TService must not be an interface.

using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Services.Description;

/// <summary>Writes a WSDL for the XML Web service at the specified URL.</summary>
/// <typeparam name="TService">A concrete implementation of the XML Web service</typeparam>
/// <param name="output">The stream to which you want to write.</param>
/// <param name="url">The address (URL) of the XML Web service.</param>
public static void Write<TService>(Stream output, string url) where TService : class
{
    var reflector = new ServiceDescriptionReflector();
    reflector.Reflect(typeof(TService), url);
    var serviceDescription = reflector.ServiceDescriptions.Cast<ServiceDescription>().Single();
    serviceDescription.Write(output);
}

/// <summary>Creates a WSDL for the XML Web service at the specified URL.</summary>
/// <typeparam name="TService">A concrete implementation of the XML Web service</typeparam>
/// <param name="url">The address (URL) of the XML Web service.</param>
public async static Task<byte[]> CreateAsync<TService>(string url) where TService : class
{
    using (var output = new MemoryStream())
    {
        await Task.Run(() => Write<TService>(output, url));
        return output.ToArray();
    }
}

cubidobusinesssolutions avatar Dec 15 '17 06:12 cubidobusinesssolutions

Where is the place for this code?

abalykov avatar Jan 19 '18 11:01 abalykov

What the result of this issue? Does smbd. have an example for this?

mh4ck avatar Jan 30 '18 15:01 mh4ck

@abalykov Sry for my late answer: The code snippet is a workaround for .wsdl generation and mimics the non-wcf SOAP clients' behaviour. For example, generating .wsdl for the sample:

public async Task<string> GetWsdl()
{
  const string url = string.Format("http://{0}:5050/Service.asmx", Environment.MachineName);
  var wsdl = await CreateAsync<SampleService.SampleServiceClient>(url);
  return System.Text.Encoding.Default.GetString(wsdl);
}

cubidobusinesssolutions avatar Mar 09 '18 05:03 cubidobusinesssolutions

See also samples/Client461/Programcs:29 where this makes problems.

cubidobusinesssolutions avatar Mar 09 '18 05:03 cubidobusinesssolutions

try it now and see extended samples under serialization tests

DmitryBryluk avatar Aug 15 '18 09:08 DmitryBryluk

Thanks, works as expected :+1:

cubidobusinesssolutions avatar Aug 20 '18 05:08 cubidobusinesssolutions

I updates samples regarding this change #121

cubidobusinesssolutions avatar Aug 20 '18 05:08 cubidobusinesssolutions