2016-04-05 24 views
3

Bir json dizesini kabul eden ve .zip dosyasını getirdiği anahtara dayanan bir web servisini uygulamaya çalışıyorum.RestEasy framework kullanarak çoklu yanıt nasıl gönderilir

Ardından, .zip dosyasını ve çok parçalı bir veride paketlenmiş bir json dizesini göndermem gerekiyor.

Yani temelde benim tepkisi gerektiği iki parça İşte

1) .zip file 
2) json string 

içeren çok parçalı nesne koşmak I yukarıda mümkün değilim benim geçerli kod

public class ContentRepo { 



@POST 
@Path("/fetchModel") 
@Consumes("application/json") 
@Produces("multipart/mixed") 
public Response getContent(String strJson) 
{ 
    Response response = null; 
    try{ 
     JSONObject objJson = new JSONObject(strJson); 
     String strAssetName = objJson.getString("assetName"); 
     if(null != strAssetName){ 
      Client client = ClientBuilder.newClient(); 
      ResteasyClient restEasyClient = (ResteasyClient) client; 
      ResteasyWebTarget target = restEasyClient.target("http://localhost:8091/ContentServer/").path("fetchModel"); 
      response = target.request() 
        .post(Entity.entity(getMultiPartData("Car"), MediaType.MULTIPART_FORM_DATA)); 
     } 
    }catch(Exception ex){ 
     ex.printStackTrace(); 
    } 

    return response; 
} 

public MultipartFormDataOutput getMultiPartData(String strAssetName){ 

    MultipartFormDataOutput objMultiPartData = new MultipartFormDataOutput(); 
    JSONObject objJson = new JSONObject(); 

    try{ 
     if(strAssetName.equalsIgnoreCase("Car")){ 
      //car assets 
      try { 
       objMultiPartData.addFormData("file", new FileBody(new File("D:/programs/content_server/Car/Car.zip")), MediaType.APPLICATION_OCTET_STREAM_TYPE); 
       objJson.put("png", "car"); 
       objMultiPartData.addFormData("mapping", new StringBody(objJson.toString()), MediaType.APPLICATION_JSON_TYPE); 
      } catch (UnsupportedEncodingException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 
     } 
    }catch(Exception ex){ 
     ex.printStackTrace(); 
    } 

    return objMultiPartData; 
} 

} Ancak

olduğu multipart yanıtı almak için. Bunun yerine bir

Caused by: java.lang.NoSuchMethodError: org.jboss.resteasy.spi.ResteasyProviderFactory.<init>(Lorg/jboss/resteasy/spi/ResteasyProviderFactory;)V 
at org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration.<init>(ClientConfiguration.java:44) 
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:347) 
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:52) 
at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114) 
at com.app.wikicontent.WikitudeContentRepo.getARModel(WikitudeContentRepo.java:45) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155) 
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) 
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) 
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) 
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525) 
... 25 more 
+0

Kullandığınız bağımlılıklar hakkında daha fazla ayrıntı gönderin. –

cevap

4

Kişisel yığın izleme o org.jboss.resteasy:resteasy-client desteklemek amacıyla değil introducedorg.jboss.resteasy:resteasy-jaxrs kadar sürüm 3.0 oldu ResteasyProviderconstructor bulamıyorum şikayet aşağıda istisna olsun. Bu nedenle, çalışma zamanı sınıf yolunuzda muhtemelen daha eski bir sürüm resteasy-jaxrs var. Bunu kaldırın ve dağıtılan uygulamanızın resteasy-jaxrs ve resteasy-client sürümlerinin senkronize olduğundan emin olun.

İlgili konular