How can JAVA client create the proxy of the WCF service which is hosted as a windows service ?


  • Hi All,

    I have created one WCF service, and I have hosted that WCF service as a windows service, and I want the JAVA client to create the proxy of that service and use it. If the WCF service is hosted as a web service then it is very easy for the JAVA client to create the proxy for that service, I want to know the solution of how JAVA can create the proxy for the WCF service which is hosted as a windows service ?

    If anybody knows the procedure, Kindly help me.

    Thanks in Advance,
    Tuesday, December 30, 2008 7:28 AM

All replies

  • Hi Venkat,
    WCF service hosted as a windows service is as good as a web service (ASMX) if you use basicHttpBinding. If the JAVA version you are using supports WS* spec, you can as well use wsHttpBinding in WCF (the service you hosted as windows service).

    JAVA would have corresponding tools for creating proxy files based on WSDL input. If you expose the metadata of the service using httpGet, you would be able to see the wsdl in a browser using the address?wsdl. Use this wsdl as input to a tool that JAVA world has to create a proxy and add it to the java project.

    For instance you can do the following:

    Using the JAX-RPC ServiceFactory to obtain a JAX-RPC Service
    String wsdlURL = http://localhost:6080/HelloWebService/services/Hello?wsdl";
    String namespace = "";
    String serviceName = "HelloWebService";
    QName serviceQN = new QName(namespace, serviceName);

    ServiceFactory serviceFactory = ServiceFactory.newInstance();
    /* The "new URL(wsdlURL)" parameter is optional */
    Service service = serviceFactory.createService(new URL(wsdlURL), serviceQN);


    Note that windows service is just a host, basically the service would have an endpoint- ABC- address, binding and contract
    using which you can fill in the above details to create the proxy. And depending on which version you want to support you
    end up using basicHttpBinding or wsHttpBinding for the B part- the binding.


    mark the post as helpful/ answered if it does...

    Tuesday, December 30, 2008 9:05 AM
  • Hi,

    Thank you very much for the response. After posting the question I realized that in the config file, I should expose the seperate "mex" bindings for the each end point i.e net.TcpBinding and as well as for the wsHttpBinding. I did these changes and installed the windows service, and tried to access the service from the IE with the help of the wsHttpBinding, it worked fine and I could also able to generate the proxy for the service running by using "SvcUtil.exe" command line utility. Even I tried to generate the proxy for the JAVA client, it was also successful. Thanks for the prompt response.

    I thought the problem got resolved, but soon when I tried to call the exposed methods from the JAVA client, it was unable to connect to the service running. In JAVA it is creating the proxy but not able to call the exposed contracts.

    Then I generated the proxy from SvcUtil.exe, It generated the Proxy.cs and output.config file in which we can see all the bindings, its addresses and the contract information. Then in the .NET client (Console Application), I added this config file and the generated Proxy.cs file and created the object by passing the "bindingConfigurationName" (which specifies end point to use, if it contains the multiple endpoints), in my case I had the two endpoints exposed, so I passed "WSHttpBinding_<ContractName>", and I could able to call the exposed operation contracts from the client.

    But in JAVA there wont be any config files generation as a result of generating the proxy. I thought this might be the reason, I might be wrong please throw some light on this problem.

    Then I tried to create the proxy using the "WSDL.exe", for the same service, then it did not create the proxy and it gave the following message

    Microsoft (R) Web Services Description Language Utility
    [Microsoft (R) .NET Framework, Version 2.0.50727.1432]
    Copyright (C) Microsoft Corporation. All rights reserved.
    Warning: one or more optional WSDL extension elements were ignored.
    Warning: one or more bindings were skipped.
    Warnings were encountered. Review generated source comments for more details.

    Error: Destination location 'WSDLHttpPath\WSDLHttpProxy.cs' could not be opened for write operation", - Could not find a part of the path 'C:\Documents and Settings\sheshavt\Desktop\WCFServiceSample\WCFServiceSample\WSDLHttpPath\WSDLHttpProxy.cs'.

    I have got struck here and first of all I would like to know, if I expose the 2 endpoints for the WCF service and host it as a Windows Service, can the JAVA clients call the exposed operation contracts or no ? if so what might be wrong in my procedure.

    Please share your thoughts on the same.

    Thanking you in Advance,
    Wednesday, December 31, 2008 12:02 PM