axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Kellogg" <rmkell...@comcast.net>
Subject RE: Attachment program using DIME
Date Wed, 08 Oct 2003 23:11:48 GMT
Please refer to the following:
http://www.mail-archive.com/axis-user@xml.apache.org/msg08732.html
http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages/DotNetInte
rop

Rick


-----Original Message-----
From: Koichi Kokura [mailto:kokimail@nifty.com] 
Sent: Wednesday, October 08, 2003 6:59 PM
To: axis-user@ws.apache.org
Subject: Attachment program using DIME

Hi Guys,

I'm trying to implement file attachment program using DIME in Axis.
I have found sample web page(Japanese) about DIME and I tried to it,
http://www.atmarkit.co.jp/fdotnet/special/wse04/wse04_04.html

But Follow message appeared, I can not success to implements.
Maybe Client program is wrong, But I can not find where is wrong.
Please help me.

Koichi.

[My Environment]
Tomcat4.1.27
AXIS1.1
WindowsXP

[Error Message]
AxisFault
 faultCode: Server.userException
 faultSubcode:
 faultString: No such operation &apos;PutData&apos;
 faultActor:
 faultNode:
 faultDetail:
 {http://xml.apache.org/axis/}stackTrace: AxisFault
 faultCode: Server.userException
 faultSubcode:
 faultString: No such operation &amp;apos;PutData&amp;apos;
 faultActor:
 faultNode:
 faultDetail:

No such operation 'PutData'
 at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.ja
va:2
60)
 at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.jav
a:16
9)
 at
org.apache.axis.encoding.DeserializationContextImpl.endElement(Deseriali
zati
onContextImpl.java:1015)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1573)
 at org.apache.crimson.parser.Parser2.content(Parser2.java:1824)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1552)
 at org.apache.crimson.parser.Parser2.content(Parser2.java:1824)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1552)
 at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:534)
 at org.apache.crimson.parser.Parser2.parse(Parser2.java:318)
 at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
 at
org.apache.axis.encoding.DeserializationContextImpl.parse(Deserializatio
nCon
textImpl.java:242)
 at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
 at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
 at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
 at org.apache.axis.client.Call.invoke(Call.java:2553)
 at org.apache.axis.client.Call.invoke(Call.java:2248)
 at org.apache.axis.client.Call.invoke(Call.java:2171)
 at org.apache.axis.client.Call.invoke(Call.java:1691)
 at DIME.AxisDIMEClient.main(AxisDIMEClient.java:63)


No such operation 'PutData'
 at
org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.ja
va:2
60)
 at
org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.jav
a:16
9)
 at
org.apache.axis.encoding.DeserializationContextImpl.endElement(Deseriali
zati
onContextImpl.java:1015)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1573)
 at org.apache.crimson.parser.Parser2.content(Parser2.java:1824)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1552)
 at org.apache.crimson.parser.Parser2.content(Parser2.java:1824)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1552)
 at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:534)
 at org.apache.crimson.parser.Parser2.parse(Parser2.java:318)
 at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
 at
org.apache.axis.encoding.DeserializationContextImpl.parse(Deserializatio
nCon
textImpl.java:242)
 at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
 at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
 at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
 at org.apache.axis.client.Call.invoke(Call.java:2553)
 at org.apache.axis.client.Call.invoke(Call.java:2248)
 at org.apache.axis.client.Call.invoke(Call.java:2171)
 at org.apache.axis.client.Call.invoke(Call.java:1691)
 at DIME.AxisDIMEClient.main(AxisDIMEClient.java:63)
Exception in thread "main"


[Server Side]
package DIME;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.xml.soap.SOAPException;

import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.attachments.Attachments;
import org.apache.axis.attachments.AttachmentPart;

public class AxisDIME {
  public String PutData(String originalName) throws SOAPException {
 try {
   MessageContext ctx = MessageContext.getCurrentContext();
   Message msg = ctx.getRequestMessage();
   AttachmentPart part
    = (AttachmentPart)msg.getAttachments().next();

   FileOutputStream fs = new FileOutputStream(
    "C:\\TEMP\\"
    + originalName);
   part.getDataHandler().writeTo(fs);
   fs.close();

   return "OK!";
 } catch (IOException ioex) {
   ioex.printStackTrace();
   throw new SOAPException("error", ioex);
 }
  }
}

[Client Side
package DIME;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;
import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import java.net.URL;


public class AxisDIMEClient {
  public static void main(String[] args) throws Exception {
 FileDialog dlg = new FileDialog(new Shell(), SWT.OPEN);
 String fileName = dlg.open();

 if (fileName != null) {
   DataHandler dhSource
    = new DataHandler(new FileDataSource(fileName));
   Service service = new Service();

   Call call = (Call)service.createCall();
   call.setTargetEndpointAddress(
     new URL("http://localhost/axis/services/AxisDIME"));
   call.setOperationStyle("wrapped");
   call.setOperationName(
    new QName("http://localhost", "PutData"));
   call.setReturnQName(
    new QName("http://localhost", "PutDataResult"));
   call.setReturnType(
    new QName("http://www.w3.org/2001/XMLSchema", "string"),
    String.class);
   call.setUseSOAPAction(true);
   call.setSOAPActionURI("http://localhost/axis/services/PutData");
   call.setEncodingStyle(null);
   call.setScopedProperty(
    org.apache.axis.client.Call.SEND_TYPE_ATTR,
    Boolean.FALSE);
   call.setScopedProperty(
    org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
    Boolean.FALSE);

   QName att = new QName("urn:DIME.AxisDIME", "DataHandler");
   call.registerTypeMapping(dhSource.getClass(),
    att, JAFDataHandlerSerializerFactory.class,
    JAFDataHandlerDeserializerFactory.class);
   call.addParameter(
    new QName("urn:DIME.AxisDIME", "originalName"),
    new QName("http://www.w3.org/2001/XMLSchema", "string"),
    String.class, ParameterMode.IN);
   call.addParameter("data", att, ParameterMode.IN);
   call.setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,
    Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);

   Object ret = call.invoke(new Object[]
    { new java.io.File(fileName).getName(), dhSource } );
 }
  }
}

[WSDD]
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="AxisDIME" provider="java:RPC">
  <parameter name="className" value="AxisDIME"/>
  <parameter name="allowedMethods" value="*"/>
</service>
</deployment>







Mime
View raw message