Создание веб-сервисов из EJB 3.0 JBoss developer studio с EAP 6.2

#web-services #jboss #ejb-3.0 #jbossws

#веб-сервисы #jboss #ejb-3.0 #jbossws

Вопрос:

Возникает проблема при создании клиентского класса / интерфейса с тем же именем «exercise.order.bean.GetAccountResp onse» уже используется. Используйте настройку класса для разрешения этого конфликта. строка 22 из /ExWeb/BusinessBean?wsdl

Вот wsdl —

     <wsdl:definitions name="BusinessBeanService" targetNamespace="http://bean.order.exercise/"><wsdl:types><xs:schema targetNamespace="http://bean.order.exercise/" version="1.0"><xs:element name="GetAccount" type="tns:GetAccount"/><xs:element name="GetAccountResponse" type="tns:GetAccountResponse"/><xs:complexType name="GetAccount"><xs:sequence><xs:element minOccurs="0" name="getAccountRequest" type="tns:getAccountRequest"/></xs:sequence></xs:complexType><xs:complexType name="getAccountRequest"><xs:sequence><xs:element minOccurs="0" name="accountID" type="xs:string"/><xs:element minOccurs="0" name="clientID" type="xs:string"/></xs:sequence></xs:complexType><xs:complexType name="GetAccountResponse"><xs:sequence><xs:element minOccurs="0" name="return" type="tns:getAccountResponse"/></xs:sequence></xs:complexType><xs:complexType name="getAccountResponse"><xs:sequence><xs:element minOccurs="0" name="accountID" type="xs:string"/><xs:element minOccurs="0" name="accountName" type="xs:string"/><xs:element minOccurs="0" name="clientID" type="xs:string"/><xs:element minOccurs="0" name="orderCount" type="xs:string"/></xs:sequence></xs:complexType></xs:schema></wsdl:types><wsdl:message name="GetAccountResponse"><wsdl:part element="tns:GetAccountResponse" name="parameters">
</wsdl:part></wsdl:message><wsdl:message name="GetAccount"><wsdl:part element="tns:GetAccount" name="parameters">
</wsdl:part></wsdl:message><wsdl:portType name="BusinessBean"><wsdl:operation name="GetAccount"><wsdl:input message="tns:GetAccount" name="GetAccount">
</wsdl:input><wsdl:output message="tns:GetAccountResponse" name="GetAccountResponse">
</wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="BusinessBeanServiceSoapBinding" type="tns:BusinessBean"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="GetAccount"><soap:operation soapAction="" style="document"/><wsdl:input name="GetAccount"><soap:body use="literal"/></wsdl:input><wsdl:output name="GetAccountResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="BusinessBeanService"><wsdl:port binding="tns:BusinessBeanServiceSoapBinding" name="BusinessBeanPort"><soap:address location="http://localhost:8080/exWeb/BusinessBean"/></wsdl:port></wsdl:service></wsdl:definitions>
 

EJB —

 @Stateless
@WebService
public class BusinessBean implements BusinessService {

@EJB private DataServiceLocal dataService;

   @Override
   @WebMethod
   @WebResult
   public GetAccountResponse GetAccount(@WebParam GetAccountRequest getAccountRequest) {

    GetAccountResponse gResponse = new GetAccountResponse();

    String clientID =  getAccountRequest.getAccountID();
    String accountID = getAccountRequest.getAccountID();

    //Find the list of order
    Order order = dataService.findOrder(accountID);

    //Find the account details
    Account account = dataService.findAccount(accountID);

    gResponse.setAccountID(accountID);
    gResponse.setAccountName(account.getAccname());
    gResponse.setClientID(clientID);
    gResponse.setOrderCount("");

    return gResponse;       

}
 

Ответ №1:

Основной причиной, скорее всего, будет используемый вами стиль параметров веб-службы. JAX-WS по умолчанию WRAPPED использует стиль параметра.

Это означает, что в WSDL уже будет GetAccountResponse тип, который представляет ответное сообщение, генерируемое вашим веб-сервисом. Этот тип (или часть) отличается и отделен от GetAccountResponse класса, который вы объявили в качестве выходных данных вашей операции веб-сервиса. Этот результат этого дублирования и есть то, что вы испытываете.

Чтобы разрешить проблему, используйте этот autoNameResolution параметр при импорте WSDL.

    wsimport BusinessBean.wsdl -B-XautoNameResolution
 

Смотрите также: