关于javawsdl缓存的信息

博主:adminadmin 2023-01-03 13:51:11 633

本篇文章给大家谈谈javawsdl缓存,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java中wsdl文件怎么生成

原则上,你可以先把JAVA生成.net的文件,然后根据以下其中一个方法,转变为WSDL

在.NET中有三种方式生成WSDL:

1.在Web Service的URL后面加上WDSL需求,如下:

2.使用disco.exe。在命令行中写下如下的命令:

disco

3.使用System.Web.Services.Description命名空间下提供的类

每个 WSDL 文件的根元素都是 definitions,必须在其中提供服务的完整描述。首先,必须在 definitions 元素中提供各种名称空间的声明。

definitions 元素包含一个或多个 portType 元素,每个元素都是一系列 operation。可以将单个portType元素看作是将各种方法组成类的一个逻辑分组。应该将每个Types称为服务,因此整个 WSDL 文件将成为一个服务集合。

在每个服务内可以有几个方法或者 operation,WSDL 通过 operation 元素来引用它们。

下面是一个最简单的WSDL例子

?xml version="1.0" encoding="UTF-8" ?

definitions name="MobilePhoneService"

targetNamespace=""

xmlns=""

xmlns:soap=""

xmlns:tns=""

xmlns:xsd=""

portType name="MobilePhoneService_port"

operation name="getListOfModels "

.......

.......

/operation

operation name="getPrice"

.......

.......

/operation

/portType

/definitions

Java调用wsdl,怎么实现

java调用wsdl的步骤如下,主要是使用第三方框架:

步骤如下:

1.下载AXIS2类库,AXIS2是目前java调用webservice的一个主要方法(由于更新较频繁,请自行google该类库的网址)

2.由于是第三方webservice,直接引入AXIS2的包就可以用了,代码如下:

import java.rmi.RemoteException;

import javax.xml.rpc.ParameterMode;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.encoding.XMLType;

 

public class webServiceTest {

    public String invokeRemoteFuc() {

        String endpoint = "";

        String result = "no result!";

        Service service = new Service();

        Call call;

        Object[] object = new Object[1];

        object[0] = "Dear I miss you";//Object是用来存储方法的参数

        try {

            call = (Call) service.createCall();

            call.setTargetEndpointAddress(endpoint);// 远程调用路径

            call.setOperationName("say");// 调用的方法名

 

            // 设置参数名:

            call.addParameter("str1", // 参数名

                    XMLType.XSD_STRING,// 参数类型:String

                    ParameterMode.IN);// 参数模式:'IN' or 'OUT'

 

            // 设置返回值类型:

            call.setReturnType(XMLType.XSD_STRING);// 返回值类型:String         

 

            result = (String) call.invoke(object);// 远程调用

        } catch (ServiceException e) {

            e.printStackTrace();

        } catch (RemoteException e) {

            e.printStackTrace();

        }

        return result;

    }

 

    public static void main(String[] args) {

        webServiceTest t = new webServiceTest();

        String result = t.invokeRemoteFuc();

        System.out.println(result);

    }

}

该方法的原理很简单,通过AXIS2封装好的类设置URL和参数,直接调用就好了,我们要关注的就是设置URL,方法,还有方法的参数,其他的copypaste好啦,很简单吧,再看看其他的方法,我勒个去了,害我瞎搞两天。迟点上个源码共大家参考!

java webservice怎么生成wsdl文件

在大多数情况下我们都需要为我们的服务提供一个WSDL文件,而 Axis2's Java2WSDL 是专门用来生成WSDL文件的D专用工具,如果你要在命令行模式下进行生成WSDL文件,首先需要保证你的环境变量AXIS2_HOME是否已经配置OK,同时还要保证把%AXIS2_HOME%\bin加入到你的path环境中,要生成 WSDL文件,首先要保证你的class能够编译成功,而且已经编译成功,然后进入class文件编译后的根目录(在JBuilder中是classes,在Eclipse中是bin目录)这时,生成WSDL文件的准备工作已经OK。\x0d\x0a\x0d\x0a下面是生成WSDL文件时的可选参数和参数说明:\x0d\x0a---------------------------------------------------------------------------------\x0d\x0aUsage java2wsdl -cn : class file name\x0d\x0a-o : output file location\x0d\x0a\x0d\x0a-cp : list of classpath entries - (urls)\x0d\x0a\x0d\x0a-tn : target namespace\x0d\x0a\x0d\x0a-tp : target namespace prefix\x0d\x0a\x0d\x0a-stn : target namespace for schema\x0d\x0a\x0d\x0a-stp : target namespace prefix for schema\x0d\x0a\x0d\x0a-sn : service name\x0d\x0a\x0d\x0a-of : output file name for the WSDL\x0d\x0a\x0d\x0a-st : style for the WSDL\x0d\x0a\x0d\x0a-u : use for the WSDL\x0d\x0a\x0d\x0a-l : address of the port for the WSDL\x0d\x0a\x0d\x0a-nsg : fully qualified name of the class that implements NamespaceGenerator\x0d\x0a\x0d\x0a-p2n [,,] ...\x0d\x0a\x0d\x0a-efd : Setting for elementFormDefault (defaults to qualified)\x0d\x0a\x0d\x0a-afd : Setting for attributeFormDefault (defaults to qualified)\x0d\x0a\x0d\x0a-xc : Extra class for which schematype must be generated.\x0d\x0aUse as : -xc class1 -xc class2 ...\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a\x0d\x0a典型地,进入你的工程的二进制编译根目录,执行命令模板如下:\x0d\x0ajava2wsdl -cp . -cn [PACKAGENAME].[CLASSNAME]-of [FILENAME].wsdl\x0d\x0a\x0d\x0a现在我们假设在samples.helloworld.service.axiom;包下面有个HelloWorldService类,工程的类文件编译后存放在build\classes目录下,那么,首先进入该目录中,然后执行以下命令:\x0d\x0ajava2wsdl -cp . -cn samples.helloworld.service.axiom.HelloWorldService -of HelloWorldService.wsdl\x0d\x0a\x0d\x0a执行后的CMD提示如下说明已经成功执行了:\x0d\x0a\x0d\x0aUsing AXIS2_HOME: D:\axis2-1.1.1\x0d\x0aUsing JAVA_HOME: C:\Program Files\Java\jdk1.5.0_06

java web项目怎么使用wsdl文件

webservice的发布一般都是使用WSDL(web service descriptive language)文件的样式来发布的,在WSDL文件里面,包含这个webservice暴露在外面可供使用的接口。

注意,以下的代码并没有经过真正的测试,只是说明这些情况,不同版本的Axis相差很大,最好以apache网站上的例子为准,这里仅仅用于说明其基本用法。

1,直接AXIS调用远程的web service,直接调用模式如下:

import java.util.Date;

import java.text.DateFormat;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import javax.xml.namespace.QName;

import java.lang.Integer;

import javax.xml.rpc.ParameterMode;

public class caClient {

public static void main(String[] args) {

try {

String endpoint = "";

//直接引用远程的wsdl文件

//以下都是套路

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(endpoint);

call.setOperationName("addUser");//WSDL里面描述的接口名称

call.addParameter("userName", org.apache.axis.encoding.XMLType.XSD_DATE,

javax.xml.rpc.ParameterMode.IN);//接口的参数

call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型

String temp = "测试人员";

String result = (String)call.invoke(new Object[]{temp});

//给方法传递参数,并且调用方法

System.out.println("result is "+result);

}

catch (Exception e) {

System.err.println(e.toString());

}

}

}

2,直接SOAP调用远程的webservice ,这种模式很少用,但是网络上有人贴出来,也转过来 :

import org.apache.soap.util.xml.*;

import org.apache.soap.*;

import org.apache.soap.rpc.*;

import java.io.*;

import java.net.*;

import java.util.Vector;

public class caService{

public static String getService(String user) {

URL url = null;

try {

url=new URL("");

} catch (MalformedURLException mue) {

return mue.getMessage();

}

// This is the main SOAP object

Call soapCall = new Call();

// Use SOAP encoding

soapCall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

// This is the remote object we're asking for the price

soapCall.setTargetObjectURI("urn:xmethods-caSynrochnized");

// This is the name of the method on the above object

soapCall.setMethodName("getUser");

// We need to send the ISBN number as an input parameter to the method

Vector soapParams = new Vector();

// name, type, value, encoding style

Parameter isbnParam = new Parameter("userName", String.class, user, null);

soapParams.addElement(isbnParam);

soapCall.setParams(soapParams);

try {

// Invoke the remote method on the object

Response soapResponse = soapCall.invoke(url,"");

// Check to see if there is an error, return "N/A"

if (soapResponse.generatedFault()) {

Fault fault = soapResponse.getFault();

String f = fault.getFaultString();

return f;

} else {

// read result

Parameter soapResult = soapResponse.getReturnValue ();

// get a string from the result

return soapResult.getValue().toString();

}

} catch (SOAPException se) {

return se.getMessage();

}

}

}

使用java根据wsdl文件生成的访问接口类调取数据反应很慢?

在接口调用方法逐行加日志,然后分析耗时长的原因呗,是否在调用前和调用后又insert日志流水到数据库?是否有更新数据库的操作?是否存在第三方认证相关的过滤器?是否存在不必要的过滤器?这些操作都有可能存在性能瓶颈,性能调优的方法一般也就是定位瓶颈代码,然后优化导致速度慢的代码。

java怎么调用wsdl csdn

直接调用模式如下:

import java.util.Date;

import java.text.DateFormat;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import javax.xml.namespace.QName;

import java.lang.Integer;

import javax.xml.rpc.ParameterMode;

public class caClient {

public static void main(String[] args) {

try {

String endpoint = "";

//直接引用远程的wsdl文件

//以下都是套路

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(endpoint);

call.setOperationName("addUser");//WSDL里面描述的接口名称

call.addParameter("userName", org.apache.axis.encoding.XMLType.XSD_DATE,

javax.xml.rpc.ParameterMode.IN);//接口的参数

call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型

String temp = "测试人员";

String result = (String)call.invoke(new Object[]{temp});

//给方法传递参数,并且调用方法

System.out.println("result is "+result);

}

catch (Exception e) {

System.err.println(e.toString());

}

}

}

关于javawsdl缓存和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。