C
chenwei_oracle
Unregistered / Unconfirmed
GUEST, unregistred user!
我在J2EE服务器上写了一个JAVA CLASS的WEB SERVICE应用,在该JAVA CLASS对一个大文本文件(二进制文件)通过BASE64Encoder处理成一个字符串,该JAVA CLASS返回一个处理后的字符串,现在我在DELPHI中通过SOAP得到了这个字符串,但是在DELPHI中通过IdDecoderMIME1.DecodeToStream解码时,总是提示:uneven size in decodestream,
我感觉我在DELPHI中解码不对,但是不知道怎么用,原各位大侠指点迷津:
WEB SERVICES JAVA CLASS 代码如下:
package mypackage2;
import java.util.*;
import java.sql.*;
import java.sql.Blob.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import sun.misc.BASE64Encoder.*;
import sun.misc.BASE64Decoder.*;
import org.apache.soap.util.mime.*;
import java.net.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.activation.*;
import sun.misc.*;
public class testblob
{
public testblob()
{
}
public String readblob()
{
String ret=new String();
try {
String connStr="jdbcracle:thin101.79.13.112:1521:test";
java.util.Properties info = new java.util.Properties() ;
Blob blob ;
Connection conn = null ;
ResultSet rset = null ;
Statement stmt = null ;
InputStream strm = null ;
int bbuffSize = 100;
byte[] bbuff = new byte[bbuffSize] ;
int bytes_read = 0 ;
byte[] temp_byte;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()) ;
info.put ("user", "aaa") ;
info.put ("password", "bbb") ;
conn = DriverManager.getConnection(connStr, info);
stmt = conn.createStatement() ;
rset = stmt.executeQuery ("select BLOB_CONTENT from osis_xxwl_b_wdb where name='F1039库及应用系统项目合同.doc'") ;
rset.next() ;
blob = (Blob)rset.getObject("BLOB_CONTENT") ;
strm = blob.getBinaryStream() ;
sun.misc.BASE64Encoder aaa=new sun.misc.BASE64Encoder();
long length=blob.length();
temp_byte=blob.getBytes((long)1,(int)length);
ret=aaa.encodeBuffer(temp_byte);
}
catch (SQLException e)
{
}
return ret;
}
}
DELPHI 的主要代码如下:
try
X := THTTPRio.Create(nil);
X.HTTPWebNode.UseUTF8InHeader := true ;
X.URL:='http://101.79.1.168:7777/blob-tys-context-root/mypackage2.testblob';
X.Service := 'urn:mypackage2.testblob';
X.Port := 'readblob';
InterfaceVariable := X as testblobPortType;
para1 := '中文';
para1 := Edit_para1.Text;
para2 := InterfaceVariable.readblob();
FBase64String:=para2;
Label_return_value.Caption := 'Return Value: ' + para1+para2;
FileName:='c:/1011.doc';
Base64Stream := TStringStream.Create(FBase64String);
OutputFile := TFileStream.Create(FileName, fmCreate);
OutputFile.Position := 0;
Base64Stream.Position := 0;
iSize:=Base64Stream.Seek(0,soFromEnd);
Base64Stream.Position:=0;
ResultCode:=Base64Stream.ReadString(iSize);
IdDecoderMIME1:=TIdDecoderMIME.Create(Nil);
IdDecoderMIME1.DecodeToStream(ResultCode,OutputFile);
首先忠心感谢:
我感觉我在DELPHI中解码不对,但是不知道怎么用,原各位大侠指点迷津:
WEB SERVICES JAVA CLASS 代码如下:
package mypackage2;
import java.util.*;
import java.sql.*;
import java.sql.Blob.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import sun.misc.BASE64Encoder.*;
import sun.misc.BASE64Decoder.*;
import org.apache.soap.util.mime.*;
import java.net.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.activation.*;
import sun.misc.*;
public class testblob
{
public testblob()
{
}
public String readblob()
{
String ret=new String();
try {
String connStr="jdbcracle:thin101.79.13.112:1521:test";
java.util.Properties info = new java.util.Properties() ;
Blob blob ;
Connection conn = null ;
ResultSet rset = null ;
Statement stmt = null ;
InputStream strm = null ;
int bbuffSize = 100;
byte[] bbuff = new byte[bbuffSize] ;
int bytes_read = 0 ;
byte[] temp_byte;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()) ;
info.put ("user", "aaa") ;
info.put ("password", "bbb") ;
conn = DriverManager.getConnection(connStr, info);
stmt = conn.createStatement() ;
rset = stmt.executeQuery ("select BLOB_CONTENT from osis_xxwl_b_wdb where name='F1039库及应用系统项目合同.doc'") ;
rset.next() ;
blob = (Blob)rset.getObject("BLOB_CONTENT") ;
strm = blob.getBinaryStream() ;
sun.misc.BASE64Encoder aaa=new sun.misc.BASE64Encoder();
long length=blob.length();
temp_byte=blob.getBytes((long)1,(int)length);
ret=aaa.encodeBuffer(temp_byte);
}
catch (SQLException e)
{
}
return ret;
}
}
DELPHI 的主要代码如下:
try
X := THTTPRio.Create(nil);
X.HTTPWebNode.UseUTF8InHeader := true ;
X.URL:='http://101.79.1.168:7777/blob-tys-context-root/mypackage2.testblob';
X.Service := 'urn:mypackage2.testblob';
X.Port := 'readblob';
InterfaceVariable := X as testblobPortType;
para1 := '中文';
para1 := Edit_para1.Text;
para2 := InterfaceVariable.readblob();
FBase64String:=para2;
Label_return_value.Caption := 'Return Value: ' + para1+para2;
FileName:='c:/1011.doc';
Base64Stream := TStringStream.Create(FBase64String);
OutputFile := TFileStream.Create(FileName, fmCreate);
OutputFile.Position := 0;
Base64Stream.Position := 0;
iSize:=Base64Stream.Seek(0,soFromEnd);
Base64Stream.Position:=0;
ResultCode:=Base64Stream.ReadString(iSize);
IdDecoderMIME1:=TIdDecoderMIME.Create(Nil);
IdDecoderMIME1.DecodeToStream(ResultCode,OutputFile);
首先忠心感谢: