Pomoc z SOAP

0

Cześć, chciałem postawić sobie serwis SOAP przy pomocy Spring Boot, i tak mam plik xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="myNamespace"
           targetNamespace="myNamespace" elementFormDefault="qualified">

    <xs:element name="getCountryTestRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="getCountryRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="name" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="getCountryTestResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="country" type="tns:country"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="getCountryResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="country" type="tns:country"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="country">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="population" type="xs:int"/>
            <xs:element name="capital" type="xs:string"/>
            <xs:element name="currency" type="tns:currency"/>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="currency">
        <xs:restriction base="xs:string">
            <xs:enumeration value="GBP"/>
            <xs:enumeration value="EUR"/>
            <xs:enumeration value="PLN"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Klasy zostały poprawnie wygenerowane, to jest mój endpoint:

0

Sorry za spam, nie dokończyłem posta.
To jest mój endpoint:

    private static final String NAMESPACE_URI = "myNamespace";

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

		return response;
	}

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

		return response;
	}

I klasa konfiguracyjna:

@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("myNamespace");
		wsdl11Definition.setSchema(countriesSchema);
		return wsdl11Definition;
	}

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

Po pobraniu wsdl i wysłaniu requestu na getCountryTestRequest, dane są poprawnie zwracane, natomiast przy wysłaniu requestu na adres getCountryReques w SOAP UI dostaje wiadomość

<faultstring xml:lang="en">unexpected element (uri:"myNamespace", local:"getCountryRequest"). Expected elements are &lt;{myNamespace}getCountryTestRequest></faultstring>

Nie bardzo już wiem co z tym zrobić może ktoś pomóc?

0

Twój endpoint pod getCountryRequest oczekuje jako argumentu **GetCountryTestRequest **a powinien oczekiwać GetCountryRequest. Zmień cały endpoint, bo response tam też masz testowy

1 użytkowników online, w tym zalogowanych: 0, gości: 1