Hi Sergey, I changed the interface to the following but I am getting null on
all the attachment.getObject() from the MultipartBody param on the service
side, the ContentDisposition is also null. What could this be?
@Path("/brokerInventory")
public interface BrokerInventoryResource
{
static final String BROKER_PART = "broker";
static final String BROKER_FILE_TYPE_PART = "brokerFileType";
static final String INSTRUMENT_TYPE_PART = "instrumentType";
static final String INVENTORY_FILE_PART = "inventoryFile";
static final String INVENTORY_FILE_HEADER = "filename";
static final String ATTACHMENT_HEADER = "attachment";
@POST
@Path("/")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String uploadBrokerInventory(final MultipartBody messageBody);
}
And this is how I am calling the service:
final String statusMessage =
WebClient.create("http://localhost:8080/fixedincomesecurities/brokerInventory").
type(MediaType.MULTIPART_FORM_DATA_TYPE).
accept(MediaType.TEXT_PLAIN_TYPE).
post(createMultipartBody(brokerInventory), String.class);
This is the code in the service:
public String uploadBrokerInventory(final MultipartBody messageBody)
{
final String brokerCode = (String)
messageBody.getAttachment(BROKER_PART).getObject();
System.out.println("=== broker : [" + brokerCode + "] ===");
final String brokerInventoryFileTypeCode = (String)
messageBody.getAttachment(BROKER_FILE_TYPE_PART).getObject();
System.out.println("=== broker file type : [" +
brokerInventoryFileTypeCode + "] ===");
final String instrumentTypeCode = (String)
messageBody.getAttachment(INSTRUMENT_TYPE_PART).getObject();
System.out.println("=== instrument type : [" + instrumentTypeCode +
"] ===");
final Attachment inventoryFileAttachment =
messageBody.getAttachment(INVENTORY_FILE_PART);
final String originalFileName =
inventoryFileAttachment.getContentDisposition().getParameter(INVENTORY_FILE_HEADER);
System.out.println("=== file name : [" + originalFileName + "]
===");
DaHoopster wrote:
>
> Thanks for your reply Sergey, the problem was in my spring application
> context configuration that the service URL had a typo.
>
>
> Sergey Beryozkin-5 wrote:
>>
>> Hi Han
>>
>> The interface looks ok. Can you let me know please, how does the actual
>> class implementing this interface look like ?
>> Make sure please it has no JAXRS related annotations, it would prevent if
>> from inheriting interface annotations.
>> Also, make sure, jaxrs:server/@address is "/" in this case and that
>> CXFServlet does not have "/brokerInventory"
>>
>> cheers, Sergey
>>
>>
>> On Fri, Apr 23, 2010 at 4:01 AM, DaHoopster
>> <[email protected]>wrote:
>>
>>>
>>> Hi,
>>>
>>> I am new to CXF and I am trying to write a service that takes some
>>> string
>>> params for configuring the service and a File which contains content
>>> that
>>> the service needs to process. I kept getting “No matching operation”
>>> exception. I am probably doing this incorrectly, could someone help me
>>> see
>>> where I got it wrong?
>>>
>>> Here is the warning message:
>>>
>>> ======================================================================================
>>> WARNING: .No operation matching request path /brokerInventory is found,
>>> HTTP
>>> Method : POST, ContentType :
>>>
>>> multipart/form-data;boundary="uuid:0aab3a08-4501-4a83-9289-dc7604728b7f";start="<broker>";start-info="text/plain";type="text/plain",
>>> Accept : text/plain,.
>>>
>>> ======================================================================================
>>>
>>>
>>> Here is my service interface:
>>>
>>> ======================================================================================
>>> @Path("/brokerInventory")
>>> public interface BrokerInventoryResource
>>> {
>>> static final String BROKER_PART = "broker";
>>> static final String BROKER_FILE_TYPE_PART = "brokerFileType";
>>> static final String INSTRUMENT_TYPE_PART = "instrumentType";
>>> static final String INVENTORY_FILE_PART = "inventoryFile";
>>>
>>> @POST
>>> @Path("/")
>>> @Produces(MediaType.TEXT_PLAIN)
>>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>>> public String uploadBrokerInventory(@Multipart(BROKER_PART) final
>>> String
>>> broker,
>>> @Multipart(BROKER_FILE_TYPE_PART)
>>> final String brokerInventoryFileType,
>>> @Multipart(INSTRUMENT_TYPE_PART)
>>> final String fixedIncomeInstrumentType,
>>> @Multipart(INVENTORY_FILE_PART)
>>> final File brokerInventoryFile);
>>> }
>>>
>>> ======================================================================================
>>>
>>>
>>> Here is the client that makes the request:
>>>
>>> ======================================================================================
>>> final ContentDisposition inventoryFileDisposition = new
>>> ContentDisposition("attachment;filename=" + file.getName());
>>>
>>> final Attachment brokerAttachment = new
>>> Attachment(BrokerInventoryResource.BROKER_PART, MediaType.TEXT_PLAIN,
>>> brokerInventory.getBroker().toString());
>>> final Attachment brokerFileTypeAttachment = new
>>> Attachment(BrokerInventoryResource.BROKER_FILE_TYPE_PART,
>>> MediaType.TEXT_PLAIN,
>>> brokerInventory.getBrokerInventoryFileType().toString());
>>> final Attachment instrumentTypeAttachment = new
>>> Attachment(BrokerInventoryResource.INSTRUMENT_TYPE_PART,
>>> MediaType.TEXT_PLAIN, brokerInventory.getInstType().toString());
>>> final Attachment inventoryFileAttachment = new
>>> Attachment(BrokerInventoryResource.INVENTORY_FILE_PART,
>>> FileUtils.openInputStream(file), inventoryFileDisposition);
>>> final MultipartBody multipartBody = new
>>> MultipartBody(Arrays.asList(new Attachment[]{
>>> brokerAttachment,
>>> brokerFileTypeAttachment,
>>> instrumentTypeAttachment,
>>> inventoryFileAttachment
>>> }));
>>>
>>> final String statusMessage =
>>> WebClient.create("
>>> http://localhost:8080/fixedincomesecurities/brokerInventory").
>>> type(MediaType.MULTIPART_FORM_DATA_TYPE).
>>> accept(MediaType.TEXT_PLAIN_TYPE).
>>> post(multipartBody, String.class);
>>>
>>>
>>> ======================================================================================
>>>
>>> Thanks,
>>> Han
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/stuck-on-multipart-tp28336934p28336934.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://old.nabble.com/stuck-on-multipart-tp28336934p28345491.html
Sent from the cxf-user mailing list archive at Nabble.com.