- - PR -
AXIS 添付ファイルの送信
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2004-09-09 13:24
お世話になります。
以前掲載されていた例を参考に DataHandlerを使用した添付ファイルの送信を試しています。 クライアントからサーバへのファイルの送信はできているようですが、 サービス一覧からサービスのwsdlを確認すると 以下のようなエラーが発生しています。 wsddのDataHandlerを引数とした場合の記述が誤っているのだと思うのですが 初心者の為、解らず困っています。 教えていただけないでしょうか。 ---エラー内容--------------------------- Fault - ; nested exception is: WSDLException: faultCode=OTHER_ERROR: Can't find prefix for 'xo'. Namespace prefixes must be set on the Definition object using the addNamespace(...) method.: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: WSDLException: faultCode=OTHER_ERROR: Can't find prefix for 'xo'. Namespace prefixes must be set on the Definition object using the addNamespace(...) method.: faultActor: faultNode: faultDetail: ---------------------------------------- ---deploy.wsdd内容---------------------- <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:ns1="xo" > <!-- Services from xoService WSDL service --> <service name="xo" provider="java:RPC" style="rpc" use="encoded"> <parameter name="wsdlTargetNamespace" value="urn:xo"/> <parameter name="wsdlServiceElement" value="xoService"/> <parameter name="wsdlServicePort" value="xo"/> <parameter name="className" value="xo_pkg.XoSoapBindingImpl"/> <parameter name="wsdlPortType" value="xo"/> <operation name="sendFile" qname="operNS:sendFile" xmlns:operNS="urn:xo" returnQName="sendFileReturn" returnType="rtns:string" xmlns:rtns="http://www.w3.org/2001/XMLSchema" > <parameter name="orgName" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/> <parameter name="in1" type="tns:DataHandler" xmlns:tns="xo"/> </operation> <parameter name="allowedMethods" value="sendFile"/> <typeMapping languageSpecificType="java:javax.activation.DataHandler" qname="ns1:DataHandler" deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory" serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </service> </deployment> ---------------------------------------- ---クライアント側(XoClient.java)------ import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.activation.FileTypeMap; import xo_pkg.*; public class XoClient{ public static void main (String[] args) throws Exception { try{ String file = "/home/test/test.java"; //送信元ファイル FileDataSource fds = new FileDataSource(file); fds.setFileTypeMap(FileTypeMap.getDefaultFileTypeMap()); DataHandler dh = new DataHandler(fds); Xo service = new XoServiceLocator().getxo(); String ret = ((XoSoapBindingStub)service).sendFile("test.java",dh); System.out.println(" ret = "+ ret +"_end"); }catch(Exception ex){ ex.printStackTrace(); } } } ---------------------------------------- ---サーバ側(XoSoapBindingImpl.java)--- package xo_pkg; import java.io.FileOutputStream; public class XoSoapBindingImpl implements xo_pkg.Xo{ public java.lang.String sendFile(java.lang.String orgName, javax.activation.DataHandler in1) throws java.rmi.RemoteException { try{ FileOutputStream fs = new FileOutputStream("/home/test/file/" + orgName); in1.writeTo(fs); fs.close(); return "ok"; }catch(Exception ex){ return "ng:"+ex.toString(); } } } ---------------------------------------- クライアント:Apache Axis サーバ:Apache Axis OS:Linux |
1