. NET invoke Java WebService simple tutorial

Source: Internet
Author: User

Java Drop WebService configuration is more complex

Tomcat + JDK + CXF + spring + (strtus) Watch your mood = =

First • Create a · WebProject

Copy the Lib in the cxf inside the library to your project ... I java vegetable acridine · Do not know which must drop ... Lazy people all put in the amount



And then start writing code. ·

Package com.ws; Import Javax.jws.WebService; @WebService public interface Ihello {public String helloword ();} package com.ws; Import Javax.jws.WebService; @WebService public class Hello implements ihello{public String Helloword () {//TODO auto-generated Method stub return "H Ello 5+x "; } }

Configure Spring

<?xml version= "1.0" encoding= "UTF-8"?> <beans "xmlns=" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws= "Http://cxf.apache.org/jaxws" xsi:schemalocation= " Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http:// Cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd "> <import resource=" classpath:meta-inf/cxf/ Cxf.xml "/> <import resource=" classpath:meta-inf/cxf/cxf-extension-soap.xml "/> <import" Classpath:meta-inf/cxf/cxf-servlet.xml "/> <jaxws:endpoint id=" Hello "implementor=" Com.ws.Hello "address="/ Hello "/> </beans>

Configure Web.xml

<?xml version= "1.0" encoding= "UTF-8"?> <web-app version= "2.4" xmlns= "Http://java.sun.com/xml/ns/j2ee" xmlns : xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "http://java.sun.com/xml/ns/j2ee http:// Java.sun.com/xml/ns/j2ee/web-app_2_4.xsd "> <welcome-file-list> <welcome-file>index.jsp</ welcome-file> </welcome-file-list> <servlet> <servlet-name>cxf</servlet-name> < Servlet-class>org.apache.cxf.transport.servlet.cxfservlet</servlet-class> <load-on-startup>1< /load-on-startup> </servlet> <servlet-mapping> <servlet-name>cxf</servlet-name> < url-pattern>/services/*</url-pattern> </servlet-mapping> <context-param> <param-name> Contextconfiglocation</param-name> <param-value>WEB-INF/beans.xml</param-value> </ Context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener </listener-class> </listener> </web-app>   

All right. Start Tomcat ·



· WebService Build Success ...

Here's a trial of. NET call it

Create a. NET Web site

Home layout a label and button

<%@ Page language= "C #" codefile= "Default.aspx.cs" inherits= "_default"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

The webservice of. NET is much simpler. Right Key engineering ... Add Web Reference



Double click button to enter click event code Edit

protected void Button1_Click (object sender, EventArgs e) {WS. HelloService _ws = new ws. HelloService (); Label1.Text = _ws. Helloword (); }

Start. NET Web site



Ha,,, that's it.

Or escape from the clutches of the Java drop, just study the bird, write down the memo.

Java Drop Development environment It is difficult to check the wrong, do not know is not my level problem amount Ha ha ha haha haha

Name:5+x

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.