webMethods 9.9 file upload issue

Dear experts,

i am using webmethods 9.9 and i am trying to upload a file in CAF. I created an IS service that decodes the input file and exposed it as a web service and now it is bound to the upload action button in my portlet.

my problem is that each time i upload a file of any type (png, txt,…) i get the following exception:

unknown type can’t serialize.

appreciate your help.

thanks,

Wanis

1 Like

I am facing the same issue. I have followed all the steps shown in

http://techcommunity.softwareag.com/web/guest/pwiki/-/wiki/Main/How+to+UploadDownload+a+File+from+MWS+To+IS

But i m facing "Unknow type can not serialize” when i m refreshing the service.

It is an urgent requirement, please share if anybody knows any thing about this.

Is this working on lower versions ? Not sure as I didn’t come across.

Thanks,

yes,

I have implemented this in lower versions(8.2) and it worked.

@Manoj, i followed the same steps in the link as well and still no luck.

please guys, help us.

Thanks

To resolve "Unknow type can not serialize” error. One minor change need to be done at the service input. The Input of DataType: Object should have Java Wrapper Type: byte

Capture.JPG

Hi,
I am unable to to bind the input stream.

getting following error while invoke service on IS

Missing required value: string

Please help how we can bind the input stream.

Virendra,

I hope the service Input is of DataType: Object and should have Java Wrapper Type: byte.

Can you elaborate how are you mapping the File Item of CAF Portlet to this input of the service.

Thanks
Manoj

Hi Manoj,

I have bind the #{FileUploadDefaultviewView.fileItem.inputStream} to input service doc array.
please refer attached screenshot.

Virendra,

create an new action at the binding.

And map the file item to the input which suppose to hold the fileContent for service as:
public String uploadAction() {
// TODO: implement java method
getTestUploadFile().getParameters().getTestUploadFile().getTestUploadFile().setFileContent(getFileItem().get());
return null;
}

you can directly map other inputs to the service from binding.

refresh the service from Upload Action method and map the action with async command or command button on UI.

public String uploadAction() {
// TODO: implement java method
getTestUploadFile().getParameters().getTestUploadFile().getTestUploadFile().setFileContent(getFileItem().get());
getTestUploadFile().refresh();
return null;
}

hi Manoj,
I didn’t find the methods .setFileContent() methods.

I can see follwing only.

getReceiveFileFormMWS3().getParameters().getReceiveFileFormMWS().getReceiveFileFormMWS().getInputDoc().setUploadedFile(getFileItem().get());

Thanks,
Virendra

Hi Manoj,

Can you please suggest how you implement the same case.

yes, that’s right.

Try the code which you have mentioned in your previous post.

getReceiveFileFormMWS3().getParameters().getReceiveFileFormMWS().getReceiveFileFormMWS().getInputDoc().setUploadedFile(getFileItem().get());

I think it should work.

Dont get confused: Here,

getTestUploadFile().getParameters().getTestUploadFile().getTestUploadFile().setFileContent(getFileItem().get());

It is setFileContent(…) because fileContent is name of the input field of service.

regards
Manoj

still getting same error.

[ISS.0086.9063] Missing required value: string
no value getting passed to IS service.

Please help me on it. not able to figure what mistake i am doing.

Thanks in advace.

please post ur porlet here

Thanks manoj for help now I am able to get byte array data on IS.

one last I faced if i tried to upload pdf of word getting cast exception. have you tried to upload such kinds of file .

you can try

below steps to Upload file of various types:

1: At IS service level, change the type of the input variable (which will hold the content) to String.

2: Suppose the name of the service is uploadFile() and name of the input variable that will hold the contnet is fileInput

3: getUploadFile().getParameters().getUploadFile().getUploadFile().setFileInput(encode(getFileItem().get()));

where FileItem is (at CAF) File Input Value holder

this encode() is :
import com.webmethods.rtl.encode.Base64;

public String encode(Object data) {
if (data instanceof String) {
return “\n” + ((String)data) + “\n”;
}
if (data instanceof byte) {
byte enc = Base64.encode((byte)(byte)data);
String s = new String(enc);
return “\n” + s + “\n”;
}
return “\n” + data.toString() + “\n”;
}

plz tell if it works

also let me know if you found some other way

Thanks Manoj for help

after changing to string and encode the at CAF it works now I am able upload any kinds of file.

Hi all,

changing the wrapper type from UNKNOWN to byte[] works but is probably not a practicable solution. It changes the WSDL as follows:

<xsd:element name="uploadFile" nillable="true" type="xsd:anyType"/>

=>

<xsd:element maxOccurs="unbounded" name="uploadFile" nillable="true" type="xsd:byte"/>

That means that every byte of the file is uploaded with an enclosing XML tag. This is a huge overhead.

The better solution is to use a String with Content type base64Binary:

<xsd:element name="uploadFile" nillable="true" type="xsd:base64Binary"/>

The client stub will generate an interface using a javax.activation.DataHandler:

getPublishMessage().getParameters().getPublishMessage().getPublishMessage().setMsgFile(new DataHandler(getFile().get(),"application/octet-stream"));

Now the file is sent as a Base64 encoded string.

Michael

Thanks Michael for sharing the details. Indeed it will be useful to someone on some day.

Thanks,