完成@Praveen答案后,您必须将变成
port原始
BindingProvider值,然后从上下文中获取值。
如果您在托管的Web服务客户端中发生异常,请不要忘记将事务标记为回滚。
@Statelesspublic class CustomerWSClient { @WebServiceRef(wsdlLocation = "/customer.wsdl") private CustomerService service; public void getCustomer(Integer customerID) throws Exception { Customer port = service.getCustomerPort(); try { port.getCustomer(customerID); } catch(Exception e) { throw e; } finally { // Get the HTTP pre here! int responseCode = (Integer)((BindingProvider) port).getResponseContext().get(MessageContext.HTTP_RESPONSE_CODE); } }}


