Axis implements Java WebService

Source: Internet
Author: User

WebService is started with xfire. Although it is very simple to do, it uses too many package implementations and requires all packages. Sometimes it is not frequently accessed, such as http: // localhost: 8080/xfire/services/, but http: // localhost: 8080/xfire/services/datasource? In this way, we can see the WSDL language again, and an error occurs when calling the program. The message means that this WebService cannot be found. helpless, and find axis, Axis provides very convenient, just need to configure in Web-INF/server-config.wsdd. when WebService is called, no errors cannot be found. the server-config.wsdd content is as follows:

xml version="1.0" encoding="UTF-8"?>deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> globalConfiguration> parameter name="adminPassword" value="admin"/> parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/> parameter name="sendXsiTypes" value="true"/> parameter name="sendMultiRefs" value="true"/> parameter name="sendXMLDeclaration" value="true"/> parameter name="axis.sendMinimizedElements" value="true"/> requestFlow> handler type="java:org.apache.axis.handlers.JWSHandler"> parameter name="scope" value="session"/> handler> handler type="java:org.apache.axis.handlers.JWSHandler"> parameter name="scope" value="request"/> parameter name="extension" value=".jwr"/> handler> requestFlow> globalConfiguration> handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/> handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/> handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/> service name="Version" provider="java:RPC"> parameter name="allowedMethods" value="getVersion"/> parameter name="className" value="org.apache.axis.Version"/> service> service name="GetControls" provider="java:RPC" style="wrapped" use="literal"> parameter name="className" value="Data.DataSource.DataSourceImpl"/> parameter name="alowedMethods" value="*"/> service> transport name="local"> responseFlow> handler type="LocalResponder"/> responseFlow> transport> transport name="http"> requestFlow> handler type="URLMapper"/> handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/> requestFlow> transport>deployment>

The code description is very clear. version and getcontrols are the two WebServices I have written. classname is the WebService class, which can be a public Java class. if the value of alowedmethods is *, all public methods in the class will become WebService methods. the WebService call method is also simple. The Code is as follows:

String xml = "
 
  "a" name="y"/>";String host = " http://localhost:8080";        String servicepath = "/WebSite/services";        String endpoint = host + servicepath;        Service service = new Service();        Call call = (Call) service.createCall();        call.setTargetEndpointAddress(new java.net.URL(endpoint));        call.setOperationName(new QName("GetControls", "GetControlsInfoToDataRow"));        call.setReturnType(XMLType.XSD_BOOLEAN);        call.addParameter("strnode", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);        Boolean ret1 = (Boolean) call.invoke(new Object[] ...{ xml });        System.out.print(ret1.booleanValue());
 

The classes to be referenced are as follows:

import org.apache.axis.client.Call;import org.apache.axis.client.Service;

Okay, so you can call it.

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.