0

/\ I don't think that It should be closed. The referenced solution didn't answer the question

I created a Spring-WS based project following the official spring.io tutorial, and I built the following xsd file:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://localhost:8080/integ/wsdl/IInterfaceERP" targetNamespace="http://localhost:8080/integ/wsdl/IInterfaceERP" elementFormDefault="qualified">

    <xs:element name="ImportERPRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bFirstLoad" type="xs:boolean"></xs:element>
                <xs:element name="iNumofEntries" type="xs:integer"></xs:element>
                <xs:element name="sView" type="xs:string"></xs:element>
                <xs:element name="iTransactionId" type="xs:integer"></xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

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

</xs:schema>

It is simple: The client send the "ImportERPRequest" values and it will receive a XML string as response.

The response is being created like this (as it should by Spring-WS):

 <SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns2:ImportERPResponse
      xmlns:ns2="http://localhost:8080/integ/wsdl/IInterfaceERP">
      <ns2:sXml>&lt;SAAF&gt;&lt;vehicle&gt;&lt;Entry&gt;&lt;vehicleId&gt;20886&lt;</ns2:sXml>
    </ns2:ImportERPResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

But, I would like to know if its possible to return the raw XML outside of "SOAP-ENV:Envelope", just like the old known XML:

<?xml version="1.0" encoding="UTF-8"?>
<SAAF>
  <vehicle>
    <Entry>
      <vehicleId>20886</vehicleId>
    </Entry>
  </vehicle>
</SAAF>

If it is not, is any other Spring solution that I can use to achieve this?

I really would like to return the entire <SAAF> inside of "SOAP-ENV:Body", but the consumer specification asks a WSDL url and it should return a raw xml as I provided above.

WitnessTruth
  • 539
  • 2
  • 9
  • 27
  • It's strange that your response is in tag sXML, as a string. The purpose of SOAP is to have an envelope, so I think you cant – ggr Nov 05 '20 at 09:44
  • @ggr I imaginated that. I know that isn't the best practice :/ but this is what I could achieve, for now.... – WitnessTruth Nov 05 '20 at 09:48
  • You can try to use a rest controller and return XML, but you will loose the wsdl. – ggr Nov 05 '20 at 10:01
  • Ehr. No. You are using a WSDL, thus soap webservice which will require a SOAP Envelope. Do you really want a SOAP Web Service or not. – M. Deinum Nov 05 '20 at 10:14
  • @ggr Yes! It was the only solution that I found until now that really returns the desired XML. But, the consumer requests a WSDL, that is what breaks me... :( – WitnessTruth Nov 05 '20 at 10:14
  • @M.Deinum I don't know... I'm just trying to do what the costumer is requesting: A Webservice with a WSDL that returns a raw XML. Can only SOAP Webservice work with WSDL's? – WitnessTruth Nov 05 '20 at 10:22
  • Then don't use SOAP in your webservice. See https://stackoverflow.com/questions/9976560/wsdl-service-for-plain-xml-instead-of-soap and see https://stackoverflow.com/questions/15486140/creating-a-spring-web-service-using-plain-old-xml-pox – M. Deinum Nov 05 '20 at 10:39

0 Answers0