Hi I'm using your Content Provider and ContentConsumer to send video data as a binary. I put your provider code in my client (portlet) and the Consumer as the service. I don't have errors when I compile but when I'm running the client/service and I try to upload a file I receive this error:
13:28:21,218 INFO [PortletHotDeployListener:202] Registering portlets for hello
Portlets
13:28:21,218 WARN [PortletLocalServiceImpl:345] Portlet with the name HelloPort
let1_WAR_helloPortlets is described in portlet.xml but does not have a matching
entry in liferay-portlet.xml
13:28:21,218 INFO [PortletHotDeployListener:209] 1 portlets for helloPortlets a
re ready for registration
13:28:21,250 INFO [PortletHotDeployListener:285] 1 portlets for helloPortlets r
egistered successfully
13:28:25,703 WARN [PortletLocalServiceImpl:148] Portlet not found for 1 HelloPo
rtlet2_WAR_helloPortlets
13:28:25,703 WARN [PortletLocalServiceImpl:148] Portlet not found for 1 HelloPo
rtlet3_WAR_helloPortlets
13:28:25,750 WARN [PortletLocalServiceImpl:148] Portlet not found for 1 HelloPo
rtlet2_WAR_helloPortlets
13:28:25,750 WARN [PortletLocalServiceImpl:148] Portlet not found for 1 HelloPo
rtlet3_WAR_helloPortlets
13:28:25,765 WARN [PortletLocalServiceImpl:148] Portlet not found for 1 HelloPo
rtlet2_WAR_helloPortlets
13:28:25,765 WARN [PortletLocalServiceImpl:148] Portlet not found for 1 HelloPo
rtlet3_WAR_helloPortlets
Received multipart/form-data; boundary=---------------------------17790175612429
setting the binary content
13:28:54,718 ERROR [jsp:60] com.sun.xml.ws.server.UnsupportedMediaException:
Uns
upported Content-Type: text/html;charset=ISO-8859-1 Supported ones are: [text/xml]
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/
html;charset=ISO-8859-1 Supported ones are: [text/xml] at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:2
91)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:1
28)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java
:287)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTr
ansportPipe.java:171)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest
(HttpTransportPipe.java:86)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(Deferre
dTransportPipe.java:116)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.client.Stub.process(Stub.java:248)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.
java:109)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.
java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
at $Proxy326.setContent(Unknown Source)
at org.weblab_project.portlet.HelloPortlet1.processAction(HelloPortlet1.
java:250)
I don't understand why it says that I'm receiving text/html;charset=ISO-8859-1
in my portlet I set the RenderResponse.setContentType("text/html");
here there is part of my code (client)
Code: BinaryContent content = new BinaryContent();
try{
FileInputStream fs = new FileInputStream(serverFile);
byte[] tab = new byte[ Math.max((int)(serverFile.length() * 1.4),40) ];
int length = 0;
int numBytes = 0;
while( ( numBytes = fs.read( tab, length, 4096 ) ) >= 0 ) {
length += numBytes;
}
content.setLimit(numBytes);
content.setData(tab);
content.setUri("weblab://myportlet/mybinarydata");
fs.close();
}
catch (IOException e){
e.printStackTrace();
}
}
}
}
URL WSDLServiceURL = null;
try {
WSDLServiceURL = new File(getPortletContext().getRealPath(
"WEB-INF/classes/wsdl/services/ResourceRepository.wsdl"))
.toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
// creating service
ResourceRepositoryService service = new ResourceRepositoryService(
WSDLServiceURL,
new QName(
"http://weblab-project.org/services/resourcerepository",
"ResourceRepositoryService"));
ContentConsumer consumer = service.getContentconsumerPort();
// setting the service URL, here service on local Tomcat
setEndpointAddress(consumer, "http://localhost:8080/contentProject",
"setContent");
SetContentArgs in = new SetContentArgs();
in.setContent(content);
String result = new String();
try {
[b]// this is the line 250[/b]
result = consumer.setContent(in).getContentId();
}
catch (SetContentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The server part is exactly as your implementation just adding the getFileFromContentId() method.
any ideas?