0

We are facing issues generating the correct SOAP request from wsdl using apache cxf-codegen-plugin. The request that is being fired by the clilent is missing the SOAP envelope and SOAP body tags. Is that something we have to do programatically or is it something that can be configured in the plugin extraargs. Steps to reproduce 1. Included the cxf-codegen-plugin maven plugin version 3.0.3 in pom 2. During generate sources the sources are generated.

When the request is fired it looks like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CalculateSomething xmlns="http://something/0.3.1/" xmlns:ns2="http://something/0.1/" xmlns:ns3="http://something"></CalculateSomething>

instead of when we try via POSTMAN (and it succeeds) the request that should generated is

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <ns3:CalculateSomething xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns3="http://something" xmlns:ns2="http://something" xmlns="http://something/0.1/">
      <ns3:request>...
    </ns3:CalculateSomething>
  </S:Body>
</S:Envelope>

Basically it looks like we are not able to generate the SOAP envelope correctly through the cxf codegen plugin, or we did not configure it properly. We have this in the pom.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.2</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
    <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/wsdl/something.wsdl</wsdl>
                        </wsdlOption>
                    </wsdlOptions>
                </configuration>
                <goals>
                    <goal>wsdl2java</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${basedir}/target/generated-sources/jaxb</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
  • It would help if you can update the question with your code where you call the SOAP service using the classes generated by cxf-codegen-plugin. – Smile Dec 06 '19 at 11:16
  • The call is going through to the server and we are getting a 500 error response back. I hope that would mean the service call is doing things right? – sonika jha Dec 06 '19 at 12:26
  • When you say call is going through to the server, is SOAP envelope and body included in request? – Smile Dec 09 '19 at 08:53
  • Your original request can't work cause it is NOT a SOAP request. All you do is sending your application-local XML over the wire, thus you get a 500. The Postman works cause it contains the required SOAP envelop items. The problem has nothing to do with cxf-codegen-plugin. Rather with the way you are invoking your client call. I guess you simply marshalled an instance of CalculateSomething.class into a String (using JAXB) and then HTTPd it to your sever .. This won't work. See CXF usage examples how to do it proper. – wh81752 Feb 17 '21 at 18:52

0 Answers0