java - C#/WCF SOAP client (without Svcutil.exe or any WSDL tool) for a SOAP-based RPC style web service endpoint created using JAX-WS -
please create c#/wcf soap client (without svcutil.exe or wsdl tool) soap-based rpc style web service endpoint created using jax-ws in following java code snippet?
for example, here's python soap client jax-ws:
import suds suds.client import client class serviceclient(object): def gethelloworld(self, arg): try: wsdl_url = 'http://localhost:9999/ws/hello?wsdl' client = client(wsdl_url) # print client result = client.service.gethelloworldasstring(arg) return result except suds.webfault f: print(f) print(f.fault) except exception e: print(e) print (serviceclient().gethelloworld('python web service client'))
the python soap client output: hello world jax-ws python web service client
considering "web services" obsolete/legacy technology , instead wcf recommended in .net, create wcf soap client corresponds aforementioned python soap client.
please note development environment notepad/gedit/gitbash/windows/linux/os x, , not use ide.
i able create wcf client, wcf service. how wcf client jax-ws (without svcutil.exe or wsdl tool)?
wcf client wcf service
using system; using system.servicemodel; namespace wcfclient { public class client { static void main() { console.writeline("press enter call server"); console.readline(); basichttpbinding binding = new basichttpbinding(); channelfactory<helloworld> factory = new channelfactory<helloworld>(binding, new endpointaddress("http://localhost:9999/ws/hello/helloworldwcfservice")); helloworld proxy = factory.createchannel(); string methodfromserver = proxy.gethelloworldasstring("wcf service client"); console.writeline(methodfromserver); console.readline(); } } [servicecontract] public interface helloworld { [operationcontract] string gethelloworldasstring(string name); } } using system; using system.servicemodel; namespace wcf { [servicecontract] public interface helloworld { [operationcontract] string gethelloworldasstring(string name); } public class helloworldimpl : helloworld { public string gethelloworldasstring(string name) { return "hello world jax-ws " + name; } } public class helloworldpublisher { static void main() { basichttpbinding binding = new basichttpbinding(); uri serviceuri = new uri("http://localhost:9999/ws/hello"); servicehost host = new servicehost(typeof(helloworldimpl), serviceuri); host.addserviceendpoint(typeof(helloworld), binding, "helloworldwcfservice"); host.open(); console.writeline("published endpoint: http://localhost:9999/ws/hello"); console.writeline("access wsdl generated deployed web service via url:"); console.writeline("http://localhost:9999/ws/hello"); console.readline(); host.close(); } } }
here's java code snippet:
// helloworldclient.java package com.sample.client; import java.net.url; import javax.xml.namespace.qname; import javax.xml.ws.service; import com.sample.ws.helloworld; public class helloworldclient { public static void main(string[] args) throws exception { url url = new url("http://localhost:9999/ws/hello?wsdl"); qname qname = new qname("http://ws.sample.com/", "helloworldimplservice"); service service = service.create(url, qname); helloworld hello = service.getport(helloworld.class); system.out.println(hello.gethelloworldasstring("java web service client")); } } // helloworldimpl.java package com.sample.ws; import javax.jws.webservice; @webservice(endpointinterface = "com.sample.ws.helloworld") public class helloworldimpl implements helloworld { @override public string gethelloworldasstring(string name) { return "hello world jax-ws " + name; } } // helloworld.java package com.sample.ws; import javax.jws.webmethod; import javax.jws.webservice; import javax.jws.soap.soapbinding; import javax.jws.soap.soapbinding.style; @webservice @soapbinding(style = style.rpc) public interface helloworld { @webmethod string gethelloworldasstring(string name); }
thanks
Comments
Post a Comment