木村 様

いつもお世話になっております。

前の続きとも思われますが、

>
> 何故か理由は分からないですが、URN:FileDownloadService
> にしてやってみたらうまくいきました。
> ...........
> 原因は環境なのか、自分が悪いなのかよく分かりませんが、とりあえず、
> urnで解決しました。
>
やはり本当の解決ではないみたいです。

今回はattachmentsを使って、アップロード用にURN:SendFileServiceを作成
したのですが、やはり同じくDataHandlerの引受渡しのところで引っかかってい
ます。

------------------
サービスのところで
public class SendFileService {
    public DataHandler echo( DataHandler dh) {
    ......
    }
}

------------------
クライントのほうは”SOAP通信”で呼んでおります。
    boolean echoUsingSAAJ(String address, String port, String filename)
throws Exception {
                String endPointURLString =  "http://"+address+":"; +port
+ "/axis/services/urn:SendFileService";
        SOAPConnectionFactory soapConnectionFactory =
javax.xml.soap.SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection =
soapConnectionFactory.createConnection();

        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();
        SOAPEnvelope requestEnvelope = soapPart.getEnvelope();
        SOAPBody body = requestEnvelope.getBody();
        SOAPBodyElement operation = body.addBodyElement(requestEnvelope.
createName("echo"));

        Vector dataHandlersToAdd = new Vector();
        dataHandlersToAdd.add(new DataHandler(new FileDataSource(new
File(filename))));

        if (dataHandlersToAdd != null) {
            ListIterator dataHandlerIterator =
dataHandlersToAdd.listIterator();

            while (dataHandlerIterator.hasNext()) {
                DataHandler dataHandler =
(DataHandler)dataHandlerIterator.next();
                javax.xml.soap.SOAPElement element =
operation.addChildElement(requestEnvelope.createName("source"));
                javax.xml.soap.AttachmentPart attachment =
soapMessage.createAttachmentPart(dataHandler);
                soapMessage.addAttachmentPart(attachment);
                element.addAttribute(requestEnvelope.createName("href"),
"cid:"; + attachment.getContentId());
            }
        }
                System.out.println("2: getDataHandler");
                Iterator iterator = null;
                DataHandler rdh =null;
                int count = 1;  // org is 3
                for(int i = 0; i < count; i++){
                        System.out.println("====== loop#" + i );
                        try {
                                javax.xml.soap.SOAPMessage
returnedSOAPMessage = soapConnection.call(soapMessage,
endPointURLString);
                                iterator =
returnedSOAPMessage.getAttachments();
                                if (!iterator.hasNext()) {
                                    //The wrong type of object that what
was expected.
                                    System.out.println("Received problem
response from server");
                                    throw new AxisFault("", "Received
problem response from server", null, null);
                                }

                        //Still here, so far so good.
                        //Now lets brute force compare the source
attachment
                        // to the one we received.
                        rdh = (DataHandler)
((AttachmentPart)iterator.next()).getDataHandler();
                                break;
                        } catch (Exception e) {
                        ....
                        }
                }
....
------------------

deploy.wsddは下記のようにoperationも入れております。

<deployment xmlns="http://xml.apache.org/axis/wsdd/";
        xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";
        xmlns:ns1="urn:SendFileService" >
        <service name="urn:SendFileService" provider="java:RPC" >
            <parameter name="className"
value="attachments.SendFileService"/>
            <parameter name="allowedMethods" value="echo echoDir"/>
            <operation name="echo" returnQName="echoResponse"
returnType="ns1:DataHandler" >
                <parameter name="dh" type="ns1:DataHandler"/>
                </operation>

            <typeMapping
deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFac
tory"
                languageSpecificType="java:javax.activation.DataHandler"
qname="ns1:DataHandler"

serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory
"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
                />
        </service>
</deployment>

------------------
結果:
Tomcatの画面では

- AxisFault:
AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.RuntimeException: java.io.IOException: End of
stream enc
ountered before final boundary marker.AxisFault
 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.io.IOException: End of stream encountered before
final bounda
ry marker.
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}stackTrace:java.io.IOException: End
of stre
am encountered before final boundary marker.
        at
org.apache.axis.attachments.BoundaryDelimitedStream.read(BoundaryDeli
mitedStream.java:308)
        at
org.apache.axis.attachments.BoundaryDelimitedStream.read(BoundaryDeli
mitedStream.java:358)
        at
org.apache.axis.attachments.ManagedMemoryDataSource.&amp;lt;init&amp;
gt;(ManagedMemoryDataSource.java:146)
.....

になってしまいました。logsにはなにも取れてません。ファイルすら存在しませ
ん。

PS: 
1.現に、URN:FileDownloadServiceは正しく動いております。URN:
SendFileService
  も同じようにやっているつもりですが、。。。
2.   public DataHandler echo( DataHandler dh) で
  DataHandlerを引き渡すときにとreturnにそれぞれエラーになる場合があっ
て不安定
  です。(これについては調べている途中です。)

なにか助言を宜しくお願い申し上げます。


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

メールによる返信