当前位置:首页 » 编程语言 » java调用asmx接口

java调用asmx接口

发布时间: 2022-03-30 19:59:27

java调用.svc 的webservice接口

DataService.svc 当成固定值就行,你是客户端,不用管服务端什么样,按照正常的wsdl开发就行

Ⅱ Java怎么调用Webservice接口(.asmx后缀)

建议使用cxf或者axis2生成客户端再去调用

Ⅲ java调用webService的问题(.asmx xml)

http://www.blogjava.net/zjhiphop/archive/2009/04/29/webservice.html

Ⅳ java语言使用post方式调用webService方式

WebService可以有Get、Post、Soap、Document四种方式调用,以下Java通过post方式调用WebService代码:

importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStream;
importjava.io.InputStreamReader;
importjava.io.OutputStream;
importjava.io.OutputStreamWriter;
importjava.net.URL;
importjava.net.URLConnection;
importjava.net.URLEncoder;
importorg.apache.cxf.endpoint.Client;
importorg.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
/**
*功能描述:WebService调用
*
*/
publicclassClientTest{
/**
*功能描述:HTTP-POST
*
*/
publicStringpost(){
OutputStreamWriterout=null;
StringBuildersTotalString=newStringBuilder();
try{
URLurlTemp=newURL(
"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity");
URLConnectionconnection=urlTemp.openConnection();
connection.setDoOutput(true);
out=newOutputStreamWriter(connection.getOutputStream(),"UTF-8");
StringBuffersb=newStringBuffer();
sb.append("byProvinceName=福建");
out.write(sb.toString());
out.flush();
StringsCurrentLine;
sCurrentLine="";
InputStreaml_urlStream;
l_urlStream=connection.getInputStream();//请求
BufferedReaderl_reader=newBufferedReader(newInputStreamReader(
l_urlStream));
while((sCurrentLine=l_reader.readLine())!=null){
sTotalString.append(sCurrentLine);
}
}catch(Exceptione){
e.printStackTrace();
}finally{
if(null!=out){
try{
out.close();
}catch(IOExceptione){
e.printStackTrace();
}
}
}
returnsTotalString.toString();
}
}

Ⅳ java怎么调用webservice接口

  1. 利用jdk web服务api实现,这里使用基于SOAP message的Web服务

  2. 使用xfire,我这里使用的是myeclipse集成的xfire进行测试的
    利用xfire开发WebService,可以有三种方法:
    1一种是从javabean 中生成;
    2 一种是从wsdl文件中生成;
    3 还有一种是自己建立webservice

  3. 使用axis1.4调用webservice方法
    前提条件:下载axis1.4包和tomcat服务器,并将axis文件夹复制到tomcat服务器的webapp文件夹中

  4. 使用axis2开发webservice

Ⅵ JAVA调用.net写的webservice接口asmx

返回一个json 格式的字符串给你,你就好处理了

Ⅶ Java客户端调用Webservice接口流程

给你看看以前写的获取电话号码归属地的代码的三种方法,然后你就懂了。

importjava.io.ByteArrayOutputStream;
importjava.io.FileInputStream;
importjava.io.IOException;
importjava.io.InputStream;
importjava.net.HttpURLConnection;
importjava.net.URL;

importorg.apache.commons.httpclient.HttpClient;
importorg.apache.commons.httpclient.HttpException;
importorg.apache.commons.httpclient.methods.PostMethod;

publicclassMobileCodeService{

publicvoidhttpGet(Stringmobile,StringuserID)throwsException
{
//http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=string&userID=string
URLurl=newURL("http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode="+mobile+"&userID="+userID);
HttpURLConnectionconn=(HttpURLConnection)url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");

if(conn.getResponseCode()==HttpURLConnection.HTTP_OK)//200
{
InputStreamis=conn.getInputStream();

=newByteArrayOutputStream();//

byte[]buf=newbyte[1024];
intlen=-1;
while((len=is.read(buf))!=-1)
{
//获取结果
arrayOutputStream.write(buf,0,len);
}

System.out.println("Get方式获取的数据是:"+arrayOutputStream.toString());
arrayOutputStream.close();
is.close();
}
}


publicvoidhttpPost(Stringmobile,StringuserID)throwsHttpException,IOException
{
//访问路径http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo
//HttpClient访问

HttpClienthttpClient=newHttpClient();
PostMethodpm=newPostMethod("http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo");

pm.setParameter("mobileCode",mobile);
pm.setParameter("userID",userID);

intcode=httpClient.executeMethod(pm);
System.out.println("状态码:"+code);

//获取结果
Stringresult=pm.getResponseBodyAsString();
System.out.println("获取到的数据是:"+result);
}

publicvoidSOAP()throwsException
{
HttpClientclient=newHttpClient();

PostMethodmethod=newPostMethod("http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx");

//设置访问方法的参数
method.setRequestBody(newFileInputStream("C:\soap.xml"));

method.setRequestHeader("Content-Type","text/xml;charset=utf-8");

intcode=client.executeMethod(method);
System.out.println("状态码:"+code);

//获取结果
Stringresult=method.getResponseBodyAsString();
System.out.println("获取到的数据是:"+result);
}

publicstaticvoidmain(String[]args)throwsException{
MobileCodeServicemcs=newMobileCodeService();
mcs.httpGet("18524012513","");
//mcs.httpPost("18524012513","");
//mcs.SOAP();
}
}

Ⅷ java怎么调用.netwebservice接口

http://blog.csdn.net/lorinzhang/article/details/6339380 希望这篇文章对你有帮助!

Ⅸ java调用webservice接口具体怎么调用啊有没有简单点的

最简单的就是直接弄一个URL类。 通过buffer得到结果。

URLtmp=newURL(url);
URLConnectionconnection=tmp.openConnection();
connection.connect();
BufferedReaderreader=newBufferedReader(newInputStreamReader(connection.getInputStream()));
Stringline;
while((line=reader.readLine())!=null){
result+=line;
result+=" ";
}
//result就是了

Ⅹ java调用 webservice 接口怎么调用

太简单了,这个跟Java访问url是一样的:

	/**
*程序中访问http数据接口
*@paramurlStrwebService地址地址
*/
(StringurlStr){
/**网络的url地址*/
URLurl=null;
/**http连接*/
HttpURLConnectionhttpConn=null;
/**//**输入流*/
BufferedReaderin=null;
StringBuffersb=newStringBuffer();
try{
url=newURL(urlStr);
in=newBufferedReader(newInputStreamReader(url.openStream(),"UTF-8"));
Stringstr=null;
while((str=in.readLine())!=null){
sb.append(str);
}
}catch(Exceptionex){
ex.printStackTrace();
}finally{
try{
if(in!=null){
in.close();
}
}catch(IOExceptionex){
ex.printStackTrace();
}
}
Stringresult=sb.toString();
System.out.println(result);
returnresult;
}

然后解析字符串就好了。是不是很简单

热点内容
phpfile乱码 发布:2025-07-16 03:57:54 浏览:93
手机存储空间扩容 发布:2025-07-16 03:52:07 浏览:861
小米4清除缓存 发布:2025-07-16 03:03:17 浏览:563
如何缓解压力英语作文 发布:2025-07-16 03:03:15 浏览:15
手机视频怎么缓存 发布:2025-07-16 02:59:05 浏览:933
安卓手机设备在哪里找 发布:2025-07-16 02:49:28 浏览:357
php建立数组 发布:2025-07-16 02:34:30 浏览:284
oracle存储过程同步 发布:2025-07-16 02:29:18 浏览:941
欧诺s买哪个配置的好 发布:2025-07-16 02:26:22 浏览:559
热点可以建立ftp吗 发布:2025-07-16 02:26:21 浏览:304