Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8342

Tag with XML generate a invalid request

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Minor
    • Resolution: Information Provided
    • None
    • None
    • None
    • None
    • Unknown

    Description

      Hello,

      To replace an old service, i have to add a new webservice (server side) to an API REST micro service.

      One of the requirements is to maintain the old request format.

      Problem: (..simplifying..)
      One tag of the request is an xmlString that contains xml declaration in data like :
      <gen: name><?xml version="1"?><root>...</root></gen: name>

       

      Request:
      <soapenv: Envelope xmlns: soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: gen = "http://www.baeldung.com/springsoap/gen">
      <soapenv: Header />
      <soapenv: Body>
      <gen: getCountryRequest>
      <gen: name><?xml version = "1" ?> <root> ... </root></ gen: name>
      </ gen: getCountryRequest>
      </ soapenv: Body>
      </ soapenv: Envelope>

      gen: name = "abcdef" works successfully

      gen: name = <? xml version = "1"?> gives error:
      2020-09-20 14: 30: 42.086 ERROR 16016 — [nio-8080-exec-5] c.sun.xml.internal.messaging.saaj.soap: SAAJ0511: Unable to create envelope from given source
      ERROR: 'The processing instruction target matching "[xX] [mM] [lL]" is not allowed.'

      Question: Is it possible to inform the XJC code generator to accept XML data in requests ?

      Thanks
      Paulo


      POM

      <! - generate server sources from xsd (soap) ->
      <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>jaxb2-maven-plugin</artifactId>
      <executions>
      <execution>
      <id>xjc</id>
      <goals>
      <goal>xjc</goal>
      </goals>
      </execution>
      </executions>
      <configuration>
      <outputDirectory>${project.build.directory}/generated-sources-srv</outputDirectory>
      <clearOutputDir>true</clearOutputDir>
      <sources>
      <source>${project.basedir} /src/main/resources/xsd/countries.xsd</source>
      </sources>
      </configuration>
      </plugin>

      ----------------
      Second try and same result:

      <plugin>
      {{ <groupId>org.apache.cxf</groupId>}}
      {{ <artifactId>cxf-codegen-plugin</artifactId>}}
      {{ <version>${cxf.version}</version>}}
      {{ <executions>}}
      {{ <execution>}}
      {{ <id>generate-sources</id>}}
      {{ <phase>generate-sources</phase>}}
      {{ <configuration>}}
      {{ <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>}}
      {{ <wsdlOptions>}}
      {{ <wsdlOption>}}
      {{ <wsdl>${basedir}/src/main/resources/countries.wsdl</wsdl>}}
      {{ </wsdlOption>}}
      {{ </wsdlOptions>}}
      {{ </configuration>}}
      {{ <goals>}}
      {{ <goal>wsdl2java</goal>}}
      {{ </goals>}}
      {{ </execution>}}
      {{ </executions>}}
      </plugin>

      Attachments

        Activity

          People

            Unassigned Unassigned
            paulomfgoncalves Paulo Goncalves
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: