SOAP Spring wsdl链接

VadOs

我在Spring应用程序中有一个端点

package hello;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import io.spring.guides.gs_producing_web_service.GetCountryRequest;
import io.spring.guides.gs_producing_web_service.GetCountryResponse;

@Endpoint
public class CountryEndpoint {
    private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service";


    private CountryRepository countryRepository;

    @Autowired
    public CountryEndpoint(CountryRepository countryRepository) {
        this.countryRepository = countryRepository;
    }

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest")
    @ResponsePayload
    public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
        GetCountryResponse response = new GetCountryResponse();
        response.setCountry(countryRepository.findCountry(request.getName()));

        return response;
    }
}

和WebService配置

package hello;

import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;

@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/ws/*");
    }

    @Bean(name = "countries")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("CountriesPort");
        wsdl11Definition.setLocationUri("/ws");
        wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
        wsdl11Definition.setSchema(countriesSchema);
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema countriesSchema() {
        return new SimpleXsdSchema(new ClassPathResource("countries.xsd"));
    }
}

我正在使用嵌入式tomcat服务器作为春季启动应用程序运行它,它可以正常启动

我也有一个测试通过

/*
 * Copyright 2014-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package hello;

import static org.junit.Assert.assertNotNull;
import io.spring.guides.gs_producing_web_service.GetCountryRequest;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.ClassUtils;
import org.springframework.ws.client.core.WebServiceTemplate;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebIntegrationTest(randomPort = true)
public class ApplicationTests {

    private Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

    @Value("${local.server.port}")
    private int port = 0;

    @Before
    public void init() throws Exception {
        marshaller.setPackagesToScan(ClassUtils.getPackageName(GetCountryRequest.class));
        marshaller.afterPropertiesSet();
    }

    @Test
    public void testSendAndReceive() {
        GetCountryRequest request = new GetCountryRequest();
        request.setName("Spain");
        assertNotNull(new WebServiceTemplate(marshaller).marshalSendAndReceive("http://localhost:"
                + port + "/ws", request));
    }

}

现在我想让wsdl能够成为客户。我已经尝试了许多链接,但是所有链接都无效。有人可以提供建议吗?

穆达萨

WSDL将在下提供http://<host>:<port>/ws/countries.wsdl例如

http:// localhost:8080 / ws / countries.wsdl

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

SOAP UI在Spring WS Soap Service中找不到依赖WSDL的XSD文件

来自分类Dev

SOAP WSDL php请求

来自分类Dev

SOAP wsdl,授权

来自分类Dev

不使用WSDL的NodeJS SOAP

来自分类Dev

SOAP for NodeJS without using WSDL

来自分类Dev

基于SOAP的WebServices和WSDL

来自分类Dev

SOAP的WSDL-REST呢?

来自分类Dev

消费SOA Suite WSDL SOAP

来自分类Dev

PHP(SOAP错误:解析WSDL)

来自分类Dev

SOAP wsdl 返回 404 not found

来自分类Dev

SOAP请求返回了wsdl而不是预期的SOAP响应

来自分类Dev

使用Spring MVC,JAVA的SOAP

来自分类Dev

Spring Boot 中的 SOAP 服务

来自分类Dev

为特定的SOAP请求创建WSDL

来自分类Dev

使用Perl的SOAP API wsdl服务调用

来自分类Dev

SOAP错误:解析WSDL:无法从'https加载

来自分类Dev

WSDL生成的SOAPClient无效的SOAP 1.1消息

来自分类Dev

更改生成的wsdl中的soap:address位置

来自分类Dev

如何在wsdl末尾更改soap地址

来自分类Dev

在Android中将SOAP与WSDL结合使用

来自分类Dev

WSDL中的SOAP Web服务端点

来自分类Dev

PHP中的非WSDL SOAP请求

来自分类Dev

SharePoint SOAP请求始终发送回WSDL

来自分类Dev

为特定的SOAP请求创建WSDL

来自分类Dev

使用Perl的SOAP API wsdl服务调用

来自分类Dev

在Android中将SOAP与WSDL结合使用

来自分类Dev

WSDL中的SOAP Web服务端点

来自分类Dev

如何使用Enunciate生成SOAP 1.2 WSDL?

来自分类Dev

在ServiceStack中使用wsdl soap服务