Java calls. NET services through CXF

Source: Internet
Author: User

During the project today, some problems encountered when the java server uses cxf to dynamically call the. net Service are as follows.

1. CXF is the OpenSource ESB Celtix of IONA and apache Incubate project merged with the so-called fastest Soap protocol stack XFire.

CXF is an implementation of a JAX-WS API.

CXF supports multiple types of binding and transport.

CXF supports service models other than JAX-WS, such as JBI, CORBA, and SCA.

2, online information: http://www.cnblogs.com/yg_zhang/archive/2010/11/15/1877658.html

3. Generate the. net web service proxy class on myeclipse, that is, web Service Client. Right-click the project and choose create> Other> MyEclipse> Web Service Client.

4, C # Call Java service reference: http://blog.csdn.net/cheng110110/article/details/6440002

5. Java and. NET call each other through wenservice: http://www.ibeifeng.com/tech.php? Id = 6105

6,

 
  1. View Code
  2. /**
  3. * PubService returns the Stirng type and the Stirng type of the parameter.
  4. */
  5. @ Override
  6. Public String PubService (String data)
  7. {
  8. String str = Usual. mEmpty;
  9. String mReturn = "0001 ";
  10. String [] mStr = data. split (",");
  11. If (mStr [0]. equals ("inlogin") & mStr [1]. equals ("inlogin "))
  12. {
  13. MReturn = "000 ";
  14. }
  15. String serviceURL = "http: // 192.168.0.35/com.net/InService.asmx ";
  16. Try
  17. {
  18. JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean ();
  19. // You can use myeclipse to create a Web Service Client and reference the. class Object.
  20. Factory. setServiceClass (InServiceSoap. class );
  21. // Specify the URL path here. If InServiceSoap is not an interface class,
  22. // The following code will report an error indicating that it is not an Interface
  23. // You must use an interface when using java cxf.
  24. Factory. setAddress (serviceURL + "? Wsdl ");
  25. // Two parameters of the QName function. The first parameter is the namespace, and the second parameter is the service name of the webservice.
  26. // The first parameter can be found when the. net service is released, that is, targetnamespace,
  27. // The second parameter can be found in the java interface implementation class, that is, serviceName.
  28. Factory. setServiceName (new QName ("http://con.java.service/", "wss "));
  29. // InServiceSoap is an interface generated by the. net web Service Client.
  30. InServiceSoap client = (InServiceSoap) factory. create ();
  31. // PublishInformation
  32. Str = client. publishInformation (mStr [0], mReturn, "20000", "dfadasd ");
  33. System. out. println ("str: Call. net interface:" + str );
  34. Client = null;
  35. Factory = null;
  36. }
  37. Catch (Exception e)
  38. {
  39. // TODO: handle exception
  40. E. printStackTrace ();
  41. }
  42. Finally
  43. {
  44. }
  45. Return mReturn;
  46. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.