WebServices Apache Axis не работает сериализация

294
23 апреля 2018, 00:19

На серверной части имеется класс с данными о клиенте

public class Employee implements Serializable {
  private static final long serialVersionUID = 1L;
  private String firstName;
  private String secondName;
  private String patronymic;
  private String position;
  public Employee() {
  }
  public Employee(String firstName, String secondName, String patronymic, String position) {
    this.firstName = firstName;
    this.secondName = secondName;
    this.patronymic = patronymic;
    this.position = position;
  }
  public String getFirstName() {
    return firstName;
  }
  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }
  public String getSecondName() {
    return secondName;
  }
  public void setSecondName(String secondName) {
    this.secondName = secondName;
  }
  public String getPatronymic() {
    return patronymic;
  }
  public void setPatronymic(String patronymic) {
    this.patronymic = patronymic;
  }
  public String getPosition() {
    return position;
  }
  public void setPosition(String position) {
    this.position = position;
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Employee employee = (Employee) o;
    if (firstName != null ? !firstName.equals(employee.firstName) : employee.firstName != null) {
      return false;
    }
    if (secondName != null ? !secondName.equals(employee.secondName)
        : employee.secondName != null) {
      return false;
    }
    if (patronymic != null ? !patronymic.equals(employee.patronymic)
        : employee.patronymic != null) {
      return false;
    }
    return position != null ? position.equals(employee.position) : employee.position == null;
  }
  @Override
  public int hashCode() {
    int result = firstName != null ? firstName.hashCode() : 0;
    result = 31 * result + (secondName != null ? secondName.hashCode() : 0);
    result = 31 * result + (patronymic != null ? patronymic.hashCode() : 0);
    result = 31 * result + (position != null ? position.hashCode() : 0);
    return result;
  }
  @Override
  public String toString() {
    return "Employee{" + "firstName='" + firstName + '\'' + ", secondName='" + secondName + '\''
        + ", patronymic='" + patronymic + '\'' + ", position='" + position + '\'' + '}';
  }
}

А также сервис, который релиазует логику поиска клиента по имени или по должности:

@WebService
public class EmployeeServiceImpl implements EmployeeService {
  @Override
  public List<Employee> findByName(String secondName) {
    EmployeeRepository employeeRepository = new EmployeeRepositoryImpl();
    List<Employee> employees = employeeRepository.read();
    List<Employee> result = new ArrayList<>();
    for (Employee employee : employees) {
      if (employee.getSecondName().equals(secondName)) {
        result.add(employee);
      }
    }
    return result;
  }
  @Override
  public List<Employee> findByPosition(String position) {
    EmployeeRepository employeeRepository = new EmployeeRepositoryImpl();
    List<Employee> employees = employeeRepository.read();
    List<Employee> result = new ArrayList<>();
    for (Employee employee : employees) {
      if (employee.getPosition().equals(position)) {
        result.add(employee);
      }
    }
    return result;
  }
}

На клиентской стороне удаленно вызывается метод поиска по имени, но вылетает ошибка:

public class HelloWorldClient {
  public static void main(String[] argv) {
    try {

       EmployeeServiceImplServiceLocator locator = new EmployeeServiceImplServiceLocator();
          EmployeeServiceImpl_PortType service = locator.getEmployeeServiceImpl();
          System.out.println(Arrays.toString(service.findByName("Runets")));
        } catch (javax.xml.rpc.ServiceException | java.rmi.RemoteException ex) {
          ex.printStackTrace();
        }
      }
    }
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.io.IOException: No serializer found for class by.runets.webservices.model.Employee in registry org.apache.axis.encoding.TypeMappingDelegate@6fe15fff
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}hostname:DESKTOP-2ROGDMI
java.io.IOException: No serializer found for class by.runets.webservices.model.Employee in registry org.apache.axis.encoding.TypeMappingDelegate@6fe15fff
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at by.runets.client.EmployeeServiceImplSoapBindingStub.findByName(EmployeeServiceImplSoapBindingStub.java:174)
    at example.HelloWorldClient.main(HelloWorldCli

ent.java:15)

READ ALSO
Эстетичное форматирование json файла

Эстетичное форматирование json файла

Я использую библиотеку Gson для сериализации в jsonДелаю я примерно вот так:

158
Как узнать длину пакета по DatagramChannel?

Как узнать длину пакета по DatagramChannel?

Вот изучаю здесь код: http://csecs

193
Что возвращает return? [требует правки]

Что возвращает return? [требует правки]

Никак не могу понять, что должен возвращать return, true или false, или же вообще какое-то значение?

127
java android Фоновое распознавание текста

java android Фоновое распознавание текста

Находил такую реализацию распознавания текста (используя гугл сервисы) архив с исходникомТам открывается подобное окно

152