我的测试代码:如下。
public class XmlTransferClientTest {
public static void main(String args[]) {
File aFile = new File("abc.xml");
FileInputStream inFile = null;
String xmlstr = "";
XmlTransferServiceClient rsc = new XmlTransferServiceClient();
XmlTransferServicePortType myType = rsc.getXmlTransferServiceHttpPort(); XFireProxy proxy = (XFireProxy) Proxy.getInvocationHandler(myType);
Client client = proxy.getClient();
client.setProperty("mtom-enabled", "true");
client.setProperty(HttpTransport.CHUNKING_ENABLED, "true");
try{
inFile =new FileInputStream(aFile);
}catch(FileNotFoundException e)
{e.printStackTrace(System.err);}
FileChannel inChannel = inFile.getChannel();
ByteBuffer buf = ByteBuffer.allocate(48);
try{
while(inChannel.read(buf)!=-1)
{
xmlstr+=new String(((ByteBuffer) buf.flip()).array());
buf.clear();
}
System.out.println("EOF reached");
inFile.close();
}catch(IOException e){
e.printStackTrace(System.err);
}
client.addOutHandler(new ClientAuthenticationHandler("xpf", "xpf7622"));
try {
int unitvalue = new Integer(1);
myType.senddatainfo(unitvalue, "001", "2006-6-7");
System.out.println("SuccessFul");
} catch (Exception e) {
System.out.println(" send data Failure");
e.toString();
return;
}
DataSource source = new ByteArrayDataSource(xmlstr.toString().getBytes(),"text/plain; charset=UTF-8");
myType.stringFromBytes(new DataHandler(source));
System.out.println("do here end...");
public class XmlTransferClientTest {
public static void main(String args[]) {
File aFile = new File("abc.xml");
FileInputStream inFile = null;
String xmlstr = "";
XmlTransferServiceClient rsc = new XmlTransferServiceClient();
XmlTransferServicePortType myType = rsc.getXmlTransferServiceHttpPort(); XFireProxy proxy = (XFireProxy) Proxy.getInvocationHandler(myType);
Client client = proxy.getClient();
client.setProperty("mtom-enabled", "true");
client.setProperty(HttpTransport.CHUNKING_ENABLED, "true");
try{
inFile =new FileInputStream(aFile);
}catch(FileNotFoundException e)
{e.printStackTrace(System.err);}
FileChannel inChannel = inFile.getChannel();
ByteBuffer buf = ByteBuffer.allocate(48);
try{
while(inChannel.read(buf)!=-1)
{
xmlstr+=new String(((ByteBuffer) buf.flip()).array());
buf.clear();
}
System.out.println("EOF reached");
inFile.close();
}catch(IOException e){
e.printStackTrace(System.err);
}
client.addOutHandler(new ClientAuthenticationHandler("xpf", "xpf7622"));
try {
int unitvalue = new Integer(1);
myType.senddatainfo(unitvalue, "001", "2006-6-7");
System.out.println("SuccessFul");
} catch (Exception e) {
System.out.println(" send data Failure");
e.toString();
return;
}
DataSource source = new ByteArrayDataSource(xmlstr.toString().getBytes(),"text/plain; charset=UTF-8");
myType.stringFromBytes(new DataHandler(source));
System.out.println("do here end...");
2006-7-14 11:16:57 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: I/O exception (java.net.ConnectException) caught when processing request:
Connection refused: connect
2006-7-14 11:16:57 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: Retrying request
2006-7-14 11:16:58 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: I/O exception (java.net.ConnectException) caught when processing request:
Connection refused: connect
2006-7-14 11:16:58 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: Retrying request
2006-7-14 11:16:59 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: I/O exception (java.net.ConnectException) caught when processing request:
Connection refused: connect
2006-7-14 11:16:59 org.apache.commons.httpclient.HttpMethodDirector executeWithR
etry
信息: Retrying request
send data Failure