После запуска приложения службы не найдены - PullRequest
0 голосов
/ 18 апреля 2019

Сначала я создал контактный файл wsdl, сгенерировал заглушки и попытался опубликовать конечную точку.Я использую среду загрузки Spring, и после запуска приложения я получаю сообщение «Службы не найдены».

Когда я проверяю консоль, я обнаруживаю, что создание службы отсутствует:

[main] oacwsfReflectionServiceFactoryBean: Создание службы

Это то, что я вижу в консоли:

.____ _ __ _ _

/ \ / ___'_ __ _ () _ __ __ _ \ \ \ \

(() ___ | '_ |' | | ' / _` | \ \ \ \

\ / ___) || ) |||||||( | |))))

'| ____ |.__ | || | || __, |/ / / /

========= | _ | ============== | ___ / = / / / _/

:: Spring Boot :: (v2.1.5.BUILD-SNAPSHOT)

2019-04-17 23: 32: 03.966 INFO 18060 --- [main] cbws.soap.WsdlfirstwsApplication: запуск WsdlfirstwsApplication на PGH-L7474CKY с PID 18060 (C: \ Users \ 5064152.eclipse \ wsdlfirstws \ target \ классы, запущенные 5064152 в C: \ Users \ 5064152.eclipse \ wswsf106wsf)-17 23: 32: 03.973 ИНФОРМАЦИЯ 18060 --- [main] cbws.soap.WsdlfirstwsApplication: активный профиль не задан, возвращаясь к профилям по умолчанию: default

2019-04-17 23: 32: 05.984 INFO18060 --- [main] osbwembedded.tomcat.TomcatWebServer: Tomcat инициализирован с портом (портами): 8080 (http)

2019-04-17 23: 32: 06.028 INFO 18060 --- [main] o.apache.catalina.core.StandardService: Запуск службы [Tomcat]

2019-04-17 23: 32: 06.029 INFO 18060 --- [main] org.apache.catalina.core.StandardEngine: Запуск сервлетадвигатель: [Apache Tomcat / 9.0.17]

2019-04-17 23: 32: 06.339 INFO 18060 --- [main] oaccC [. [Localhost]. [/ Wsdlfirstws]: Инициализация встроенного Spring Spring WebApplicationContext

2019-04-17 23: 32: 06.339 INFO 18060 --- [main] osweb.context.ContextLoader: Root WebApplicationContext: инициализация завершена за 2281 мс

2019-04-17 23: 32: 06.921 INFO 18060 --- [main] ossconcurrent.ThreadPoolTaskExecutor: Инициализация ExecutorService 'applicationTaskExecutor'

1051 * 2019-04-17 23: 32: 07.376 ИНФОРМАЦИЯ 18060 --- [main] osbwembedded.tomcat.TomcatWebServer: Tomcat запущен на портах: 8080 (http) с контекстным путем '/ wsdlfirstws'

2019-04-17 23: 32: 07.381 INFO 18060 --- [main] cbws.soap.WsdlfirstwsApplication: запуск WsdlfirstwsApplication через 3,948 секунды (JVM работает для 5,023)

WSDL file:

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://trainings.ws.bharath.com/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
    name="CustomerOrdersService" targetNamespace="http://trainings.ws.bharath.com/">
    <wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://trainings.ws.bharath.com/" elementFormDefault="unqualified"
        targetNamespace="http://trainings.ws.bharath.com/" version="1.0">

        <xs:complexType name="order">
            <xs:sequence>
                <xs:element name="id" type="xs:integer" />
                <xs:element maxOccurs="unbounded" name="product" type="tns:product" />
            </xs:sequence>
        </xs:complexType>

        <xs:complexType name="product">
            <xs:sequence>
                <xs:element minOccurs="0" name="id" type="xs:string" />
                <xs:element minOccurs="0" name="description" type="xs:string" />
                <xs:element minOccurs="0" name="quantity" type="xs:integer" />
            </xs:sequence>
        </xs:complexType>

        <xs:element name="getOrdersRequest" type="tns:getOrdersRequest" />

        <xs:element name="getOrdersResponse" type="tns:getOrdersResponse" />

        <xs:complexType name="getOrdersRequest">
            <xs:sequence>
                <xs:element minOccurs="0" name="customerId" type="xs:integer" />
            </xs:sequence>
        </xs:complexType>

        <xs:complexType name="getOrdersResponse">
            <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="order"
                    type="tns:order" />
            </xs:sequence>
        </xs:complexType>

        <xs:element name="createOrdersRequest" type="tns:createOrdersRequest" />

        <xs:element name="createOrdersResponse" type="tns:createOrdersResponse" />

        <xs:complexType name="createOrdersRequest">
            <xs:sequence>
                <xs:element name="customerId" type="xs:integer" />
                <xs:element name="order" type="tns:order" />
            </xs:sequence>
        </xs:complexType>

        <xs:complexType name="createOrdersResponse">
            <xs:sequence>
                <xs:element name="result" type="xs:boolean" />
            </xs:sequence>
        </xs:complexType>

        </xs:schema>
    </wsdl:types>

    <wsdl:message name="getOrdersRequest">
        <wsdl:part element="tns:getOrdersRequest" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="getOrdersResponse">
        <wsdl:part element="tns:getOrdersResponse" name="parameters">
        </wsdl:part>
    </wsdl:message>

    <wsdl:message name="createOrdersRequest">
        <wsdl:part element="tns:createOrdersRequest" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="createOrdersResponse">
        <wsdl:part element="tns:createOrdersResponse" name="parameters">
        </wsdl:part>
    </wsdl:message>

    <wsdl:portType name="CustomerOrdersPortType">
        <wsdl:operation name="getOrders">
            <wsdl:input message="tns:getOrdersRequest" name="getOrdersRequest">
            </wsdl:input>
            <wsdl:output message="tns:getOrdersResponse" name="getOrdersResponse">
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="createOrders">
            <wsdl:input message="tns:createOrdersRequest" name="createOrdersRequest">
            </wsdl:input>
            <wsdl:output message="tns:createOrdersResponse" name="createOrdersResponse">
            </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="CustomerOrdersServiceSoapBinding"
        type="tns:CustomerOrdersPortType">
        <soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="getOrders">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="getOrdersRequest">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="getOrdersResponse">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="createOrders">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="createOrdersRequest">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="createOrdersResponse">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="CustomerOrdersService">
        <wsdl:port binding="tns:CustomerOrdersServiceSoapBinding"
            name="CustomerOrdersPort">
            <soap:address
                location="http://localhost:8080/wsdlfirstws/services/customerOrdersService" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>




Impl file as below:

package com.bharath.ws.soap;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.cxf.feature.Features;

import com.bharath.ws.trainings.CreateOrdersRequest;
import com.bharath.ws.trainings.CreateOrdersResponse;
import com.bharath.ws.trainings.CustomerOrdersPortType;
import com.bharath.ws.trainings.GetOrdersRequest;
import com.bharath.ws.trainings.GetOrdersResponse;
import com.bharath.ws.trainings.Order;
import com.bharath.ws.trainings.Product;


@Features(features="org.apache.cxf.feature.LoggingFeature")

public class CustomerOrdersWsImpl implements CustomerOrdersPortType {

    Map<BigInteger,List<Order>> customerOrders =new HashMap<>();
    int currentId;


    public CustomerOrdersWsImpl() {
        init();
    }



    private void init() {

        List<Order> orders =new ArrayList<>();

        Order order =new Order();
        order.setId(BigInteger.valueOf(1));


        Product product =new Product();
        product.setId("1");
        product.setDescription("IPhone");
        product.setQuantity(BigInteger.valueOf(5));

        order.getProduct().add(product);

        orders.add(order);

        customerOrders.put(BigInteger.valueOf(++currentId), orders);

    }



    @Override
    public GetOrdersResponse getOrders(GetOrdersRequest request) {

        BigInteger customerId = request.getCustomerId();
        List<Order> orders = customerOrders.get(customerId);

        GetOrdersResponse response = new GetOrdersResponse();
        response.getOrder().addAll(orders);

        return response;
    }

    @Override
    public CreateOrdersResponse createOrders(CreateOrdersRequest request) {
        BigInteger customerId = request.getCustomerId();
        Order order =new Order();

        List<Order> orders = customerOrders.get(customerId);
        orders.add(order);

        CreateOrdersResponse response = new CreateOrdersResponse();
        response.setResult(true);

        return response;
    }

}



Configuration file:

package com.demo.ws.soap.config;


import javax.xml.ws.Endpoint;

import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.bharath.ws.soap.CustomerOrdersWsImpl;

@Configuration
public class WebServiceConfig {

    @Autowired
    private Bus bus;

    @Bean
    public Endpoint endpoint() {
        Endpoint endpoint = new EndpointImpl(bus, new CustomerOrdersWsImpl());

        endpoint.publish("/customerordersservice");
        return endpoint;

    }
}



Pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.5.BUILD-SNAPSHOT</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.bharath.ws.soap</groupId>
    <artifactId>wsdlfirstws</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>wsdlfirstws</name>
    <description>Top down WS</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
            <version>3.3.0</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/CustomerOrders.wsdl</wsdl>
                                    <wsdlLocation>classpath:CustomerOrders.wsdl</wsdlLocation>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </pluginRepository>
    </pluginRepositories>

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