Skip to content

Commit

Permalink
WSDL local file URL replacement with classpath URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli Ver committed Feb 24, 2018
1 parent 65f119d commit 14012e6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,19 @@ protected Object[] processResult(Message message,
throw ex;
}

if (resList == null
&& oi != null && !oi.getOperationInfo().isOneWay()) {

BindingOperationInfo boi = oi;
if (boi.isUnwrapped()) {
boi = boi.getWrappedOperation();
}
if (!boi.getOutput().getMessageParts().isEmpty()) {
//we were supposed to get some output, but didn't
throw new IllegalStateException("Response message did not contain proper response data. Expected: "
+ boi.getOutput().getMessageParts().get(0).getConcreteName());
}
}
if (resList != null) {
return resList.toArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,35 @@ public String getUri() {
public void setUri(String uri) {
wsdl = uri;
}

/**
* Calls {@link Option#merge(Option)} and checks afterwards, if a classpath
* replacement string has been set as default option.<br>
* <br>
* A classpath replacement string in the format
* "classpath;/path/to/replace/" will be processed to replace the local
* file-Url of the WSDL-files with the classpath URL.<br>
* <br>
* Example: "file:/path/to/package1/package2/myservice.wsdl" will be converted
* to "classpath:/package1/package2/myservice.wsdl", if "classpath;/path/to/"
* has been set<br>
*
* @see org.apache.cxf.maven_plugin.wsdl2java.Option#merge(org.apache.cxf.maven_plugin.wsdl2java.Option)
*/
@Override
public void merge(Option defaultOptions) {
super.merge(defaultOptions);
if (!isSetWsdlLocation() && defaultOptions.isSetWsdlLocation()) {
String defaultWsdlLocation = defaultOptions.getWsdlLocation();
if (defaultWsdlLocation != null && defaultWsdlLocation.startsWith("classpath;")) {
try {
String[] replacer = defaultWsdlLocation.split(";");
String filePath = new File(replacer[1]).toURI().toURL().toExternalForm();
this.wsdlLocation = this.getWsdl().replace(filePath, "classpath:/");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPFaultException;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
Expand All @@ -35,7 +36,6 @@
/**
* Test what happens when we make an invocation and get back an empty SOAP Body (see CXF-7653)
*/
@org.junit.Ignore("Ignoring this until CXF-7653 is resolved")
public class EmptySOAPBodyTest extends AbstractBusClientServerTestBase {
static final String PORT = allocatePort(EmptySOAPBodyServer.class);

Expand Down Expand Up @@ -74,7 +74,13 @@ public void testPlaintext() throws Exception {
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);

port.doubleIt(25);
try {
port.doubleIt(25);
fail("Should have thown an exception");
} catch (SOAPFaultException t) {
assertTrue("Wrong exception cause " + t.getCause(),
t.getCause() instanceof IllegalStateException);
}

((java.io.Closeable)port).close();

Expand Down

0 comments on commit 14012e6

Please sign in to comment.