1. Java Web Service类DocumentFileManagement:
import java.io.*;
/**
* @author tyrone
*
*/
public class DocumentFileManagement {
//文件名, 文件内容,保存到d盘根目录
public String saveFile(String filename,byte[] contents){
if (filename==null || contents==null)
return "null";
String filepath="d:\\";
File fp=new File(filepath+filename);
try{
BufferedOutputStream op=new BufferedOutputStream(new FileOutputStream(fp));
op.write(contents,0,contents.length);
op.flush();
op.close();
if(fp.exists())
return fp.getAbsolutePath();
else
return "failure to create";
}catch(java.io.IOException e){
return e.getMessage();
}
}
}
2 部署到Axis服务器:
生成depoy.wsdd
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="DocumentFileManagement" provider="java:RPC">
<parameter name="className" value="DocumentFileManagement"/>
<parameter name="allowedMethods" value="saveFile"/>
</service>
</deployment>
命令行:/>AdminClient depoy.wsdd
3. copy DocumentFileManagement .class 到 axis\WEB-INF\classes目录
4. 用.NET的wsdl.exe生成VB.NET客户端类
命令行:/>wsdl /language:vb http://localhost:8080/axis/services/DocumentFileManagement?wsdl
生成DocumentFileManagementService.vb
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.573
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization
'
'This source code was auto-generated by wsdl, Version=1.1.4322.573.
'
'<remarks/>
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Web.Services.WebServiceBindingAttribute(Name:="DocumentFileManagementSoapBinding", [Namespace]:="http://localhost:8080/axis/services/DocumentFileManagement")> _
Public Class DocumentFileManagementService
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
'<remarks/>
Public Sub New()
MyBase.New
Me.Url = "http://localhost:8080/axis/services/DocumentFileManagement"
End Sub
'<remarks/>
<System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace:="http://DefaultNamespace", ResponseNamespace:="http://localhost:8080/axis/services/DocumentFileManagement")> _
Public Function saveFile(ByVal in0 As String, <System.Xml.Serialization.SoapElementAttribute(DataType:="base64Binary")> ByVal in1() As Byte) As <System.Xml.Serialization.SoapElementAttribute("saveFileReturn")> String
Dim results() As Object = Me.Invoke("saveFile", New Object() {in0, in1})
Return CType(results(0),String)
End Function
'<remarks/>
Public Function BeginsaveFile(ByVal in0 As String, ByVal in1() As Byte, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
Return Me.BeginInvoke("saveFile", New Object() {in0, in1}, callback, asyncState)
End Function
'<remarks/>
Public Function EndsaveFile(ByVal asyncResult As System.IAsyncResult) As String
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),String)
End Function
End Class
5. 调用DocumentFileManagementService.vb
Module Module1
Sub Main()
Dim ws As New DocumentFileManagementService
Dim result As String
'connect colimas web service
Dim contents As Byte
Dim fp As System.IO.File
Dim str As System.IO.FileStream
Dim fpname As String
Dim i As Integer
'上传的文件名
fpname = "StevenMills.doc"
str = fp.Open(fpname, 3)
Dim content(str.Length) As Byte
For i = 0 To str.Length - 1
content(i) = str.ReadByte()
Next
Try
'调用WebService的方法
result = ws.saveFile(fpname, content)
Console.Write(result)
Catch ex As Exception
Console.Write(ex.Message())
End Try
End Sub
End Module
分享到:
相关推荐
cxf客户端调用axis服务端流程
cxf客户端调用axis服务端流程.docxcxf客户端调用axis服务端流程.docx
本方法是用axis1.4技术,实现java客户端调用webservice。已经可实现过可行的,如果不行可加我QQ号302633进行详细解析。
axis2客户端调用axis1服务接口 调用方式 使用RPC方式调用WebService,为了防止冲突可以增加 // 与weblogic的lib冲突配置 System.setProperty("javax.xml.stream.XMLInputFactory", ...
NULL 博文链接:https://goldlive.iteye.com/blog/623828
AXIS2客户端调用实例 AXIS2客户端调用实例 AXIS2客户端调用实例 AXIS2客户端调用实例
Axis客户端调用代码,使用WSDL2JAVA生成的客户端,可以直接进行调用
Axis2教程和java调用webservice的各种方法总结
Axis开发Web Service实例,介绍AXIS的三种方法
java axis客户端调用webservice,可应用于ofbiz框架。 解决网络上共享代码两次调用后会出现timeout的BUG
cxf_axis_xfire客户端调用的几种方法[收集].pdf
axis1.4生成访问客户端代码
使用Java+Axis2调用Web Services 网络接口,代码中列举4个例子可以查看,有详细注释提供参考。
axis2客户端调用服务端,带用户身份认证
axis2客户端,调用带ntlm认证的web service的代码例子和所需jar和java
简单地描述下怎么使用 eclipse 生成 Axis2 Web Service 客户端。
axis1实现webservice 及客户端调用方法 实现
axis2客户端调用工程代码