spring-ws .wsdl не содержит ObjectFactory.class или jaxb.index - PullRequest
0 голосов
/ 02 ноября 2018

Я следую весеннему руководству по созданию клиента веб-сервиса. Во-первых, я создаю сервер, и у меня нет проблем. Я сгенерировал банку и выполнил ее. Возвращает ответ.

Это мои предложения:

InventoryClient.java

public class InventoryClient extends WebServiceGatewaySupport {

    public CatalogResponse getCatalog(Catalog cataog) {

        Catalog request = new Catalog();

        CatalogResponse response = (CatalogResponse) getWebServiceTemplate()
                .marshalSendAndReceive("http://localhost:8080/ws/", request,
                        new SoapActionCallback(
                                "http://com.uciext.ws.hw5/Catalog"));

        return response;
    }

}

InventoryConfiguration.java

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;

    @Configuration
    public class InventoryConfiguration {

        @Bean
        public Jaxb2Marshaller marshaller() {
            Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
            // this package must match the package in the <generatePackage> specified in
            // pom.xml
            marshaller.setContextPath("inventory.wsdl");
            return marshaller;
        }

        @Bean
        public InventoryClient getCatalog(Jaxb2Marshaller marshaller) {
            InventoryClient client = new InventoryClient();
            client.setDefaultUri("http://localhost:8080/ws");
            client.setMarshaller(marshaller);
            client.setUnmarshaller(marshaller);
            return client;
        }
}

Application.java

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
        Util.log("---- Application: args[1] "+args[0]);
    }

    @Bean
    void  lookup(InventoryClient inventoryClient) {



           Catalog catalog = new Catalog();

            CatalogResponse response = inventoryClient.getCatalog(catalog);
            Util.log("---- Application: date"+response.getReturn().getLastModifiedDate());

    }
}

Когда я выполняю банку, я получаю следующую ошибку

Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "inventory.wsdl" doesnt contain ObjectFactory.class or jaxb.index
 - with linked exception:
[javax.xml.bind.JAXBException: "inventory.wsdl" doesnt contain ObjectFactory.class or jaxb.index]

Когда я создал сервер, я сгенерировал классы из inventory.xsd

1 Ответ

0 голосов
/ 23 апреля 2019

Попробуйте сделать пакет wsdl, созданный jaxb непосредственно в пакете JAVA

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...