无法从wadl生成球衣客户端的无效方法

问题描述:

我正在使用球衣。 我得休息法:无法从wadl生成球衣客户端的无效方法

@PUT 
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) 
@Path("/create-profile") 
public void createProfile (Profile profile) throws UnableTransferToEntity { 
    EntityManager em = emf.createEntityManager(); 
    try{ 
     em.getTransaction().begin(); 
     em.persist(EntityConversionUtils.transformReporterProfileToSimpleProfileEntity(profile)); 
     em.getTransaction().commit(); 
    }finally{ 
     em.close(); 
    } 
} 

WADL的这种方法生成的部分:

<resource path="/create-profile"> 
      <method id="createProfile" name="PUT"> 
       <request> 
        <representation mediaType="application/json"/> 
        <representation mediaType="application/xml"/> 
       </request> 
      </method> 
     </resource> 

我使用Maven的插件生成客户端:

<groupId>org.jvnet.ws.wadl</groupId> 
      <artifactId>wadl-maven-plugin</artifactId> 
      <version>1.1-SNAPSHOT</version> 

问题是没有void方法(putApplicationXml Asvoid)生成,只有需要响应的方法。当我尝试使用它们,即使使用Void.class,我也会捕获异常(返回响应状态204无内容)。

如果其他方法包含@QueryParam:

@DELETE 
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) 
@Path("/remove-profile") 
public void removeProfile (@QueryParam("id") final int id){ 
    EntityManager em = emf.createEntityManager(); 
    SimpleProfileEntity simpleProfileEntity = em.find(SimpleProfileEntity.class, id); 

    new NotificationService().removeProfile(simpleProfileEntity.getNotificationProfile().getId()); 

    try{ 
     em.getTransaction().begin(); 
     em.remove(simpleProfileEntity); 
     em.getTransaction().commit(); 
    }finally{ 
     em.close(); 
    } 
} 

然后WADL看起来像:

<resource path="/remove-profile"> 
      <method id="removeProfile" name="DELETE"> 
       <request> 
        <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="id" style="query" type="xs:int"/> 
       </request> 
      </method> 
     </resource> 

正如你可以看到它包含 “参数” 节点。 此条目的无效客户端方法生成良好。

如何为我的CreateProfile生成void方法?

响应类型205是正确的。

我运行在同一个问题,它接缝,它是客户端部分的问题,但不是服务器部分。

我用resource.type(MediaType.APPLICATION_JSON).put(String.class, datenJson);并得到相同的例外。

它取出预期收益类型(put(String.class的第一paremter))后的工作:

resource.type(MediaType.APPLICATION_JSON).put(datenJson); 

如果你没有任何反应,使不指定预期的响应类型。