3

Here's how I start my web service:

try
{
    //load the shedluer static constructor
    ServiceHost svh = new ServiceHost(typeof(OrderExecutor));

    var tcpbinding = new NetTcpBinding(SecurityMode.None);

    //remove limits on the max array size
    var httpLocation = "http://" + address + ":1234";

    svh.AddServiceEndpoint(typeof(IOrderExecutor), new WSHttpBinding(SecurityMode.None), httpLocation);

    ServiceMetadataBehavior smb = svh.Description.Behaviors.Find<ServiceMetadataBehavior>();

    if (smb == null)
        smb = new ServiceMetadataBehavior();

    smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
    svh.Description.Behaviors.Add(smb);

    // Add MEX endpoint

    svh.AddServiceEndpoint(
                ServiceMetadataBehavior.MexContractName,
                MetadataExchangeBindings.CreateMexHttpBinding(),
                httpLocation + "/mex"
                );


    svh.Open();
    Console.WriteLine("Service mounted at {0}", httpLocation);
    Console.WriteLine("Press Ctrl+c to exit");

    var re = new ManualResetEvent(false);
    re.WaitOne();
    svh.Close();
}
catch (Exception e)
{
    Console.WriteLine("Exception");
    Console.WriteLine(e);
} 

The service starts and works ok, Visual studio can connect to it and create a working client.

But, I need a WSDL file to make it inter-operate with PHP.

I've tried

http://localhost:1234?wsdl
http://localhost:1234/IOrderExecutor?wsdl
http://localhost:1234/IOrderExecutor.wsdl

without any success.

I've also tried

svcutil /serviceName:IOrderExecutor order-executor.exe

With following result:

Warning: Unable to load a service with configName 'IOrderExecutor'. To export
 a service provide both the assembly containing the service type and an executab
le with configuration for this service.
    Details:Either none of the assemblies passed were executables with configura
tion files or none of the configuration files contained services with the config
 name 'IOrderExecutor'.

Warning: No metadata files were generated. No service contracts were exported.
 To export a service, use the /serviceName option. To export data contracts, spe
cify the /dataContractOnly option. This can sometimes occur in certain security
contexts, such as when the assembly is loaded over a UNC network file share. If
this is the case, try copying the assembly into a trusted environment and runnin
g it.

How do I get a WSDL file from a running WCF service?

Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224
  • http://stackoverflow.com/questions/4860408/what-is-wsdl-uri-in-wcf – Jonathon Reinhart May 15 '13 at 08:03
  • No result for http://localhost:1234/IOrderExecutor.asmx?WSDL either – Arsen Zahray May 15 '13 at 08:04
  • @ArsenZahray than is something wrong. "...asmx?wsdl" sould be if you have deployed properly –  May 15 '13 at 08:05
  • any idea what could be wrong here? – Arsen Zahray May 15 '13 at 08:08
  • The wsdl could also be `.svc?wsdl` instead of `.asmx?wsdl` and you should use the service name instead of the interface. – Silvermind May 15 '13 at 08:13
  • I've set httpLocation = "http://" + address + ":1234/myservice"; and tried http://localhost:1234/myservice.svc?wsdl and http://localhost:1234/myservice.asmx?wsdl. In both cases I've got 503 (sevice unavaliable). http://localhost:1234/myservice?wsdl is avaliable and returns empty page – Arsen Zahray May 15 '13 at 08:21
  • Could you try to only open `http://localhost:1234` and then browse to the service listed there? – Silvermind May 15 '13 at 09:01
  • Did you tried to use your mex endpoint? MEX = metadata exchange, I could be wrong, but metadata is passed as WSDL. http://localhost:1234/mex – insomnium_ May 16 '13 at 13:59
  • the service does create mex endpoint. At the end I solved the issue by using visual studio to connect to it and create client endpoint. Among the files for the client endpoint, there was the wdsl file. – Arsen Zahray May 18 '13 at 19:46

3 Answers3

3

have you tried localhost:1234/IOrderExecutor/?wsdl

try this it may works

Feras Salim
  • 438
  • 7
  • 33
  • Whoa, I've tried /wsdl ?wsdl /mex?wsdl /mex/wsdl /basic?wsdl /basic/wsdl (i have two endpoints, and ) and didn't tried /?wsdl.. WTF. Thanks for help. – Bomberlt Jan 16 '14 at 10:24
0

your answer lies here

// Add MEX endpoint

svh.AddServiceEndpoint(
            ServiceMetadataBehavior.MexContractName,
            MetadataExchangeBindings.CreateMexHttpBinding(),
            httpLocation + "/mex"
            );

EDIT: httpLocation + "/mex" is the address where you get the wsdl. also behaviours httpGetEnabled must be true

maxlego
  • 4,864
  • 3
  • 31
  • 38
0

To view wsdl you need to enable MetaData be setting serviceMetadata as below.

< serviceMetadata httpGetEnabled="**true**" / >
perror
  • 7,071
  • 16
  • 58
  • 85