-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JBWS-4429] NPE when SOAP request with mismatched targetNameSpace is received #539
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws4429/HelloService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jboss.test.ws.jaxws.cxf.jbws4429; | ||
|
||
import jakarta.jws.WebMethod; | ||
import jakarta.jws.WebParam; | ||
import jakarta.jws.WebResult; | ||
import jakarta.jws.WebService; | ||
import jakarta.xml.bind.annotation.XmlSeeAlso; | ||
import jakarta.xml.ws.RequestWrapper; | ||
import jakarta.xml.ws.ResponseWrapper; | ||
|
||
@WebService(name = "HelloServiceService", targetNamespace = "http://com.redhat.gss.example.soap/") | ||
@XmlSeeAlso({ | ||
ObjectFactory.class | ||
}) | ||
public interface HelloService { | ||
|
||
@WebMethod | ||
@WebResult(targetNamespace = "") | ||
@RequestWrapper(localName = "sayHello", targetNamespace = "http://com.redhat.gss.example.soap/", | ||
className = "org.jboss.test.ws.jaxws.cxf.jbws4429.SayHello") | ||
@ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://com.redhat.gss.example.soap/", | ||
className = "org.jboss.test.ws.jaxws.cxf.jbws4429.SayHelloResponse") | ||
String sayHello( | ||
@WebParam(name = "arg0", targetNamespace = "") | ||
String arg0); | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...tsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws4429/HelloServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jboss.test.ws.jaxws.cxf.jbws4429; | ||
|
||
import jakarta.ejb.Stateless; | ||
import jakarta.jws.HandlerChain; | ||
import jakarta.jws.WebMethod; | ||
import jakarta.jws.WebService; | ||
|
||
@Stateless | ||
//@WebService(targetNamespace ="http://com.redhat.gss.example.soap/") // correct targetNamespace | ||
@WebService(targetNamespace ="http://com.redhat.gss.invalid/") // invalid targetNamespace that is not matched with wsdl distributed to clients | ||
@HandlerChain(file = "/handlers.xml") | ||
public class HelloServiceImpl { | ||
@WebMethod | ||
public String sayHello(String name) { | ||
return "Hello, " + name; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...ite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws4429/HelloServiceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jboss.test.ws.jaxws.cxf.jbws4429; | ||
|
||
import java.net.URL; | ||
import javax.xml.namespace.QName; | ||
import jakarta.xml.ws.Service; | ||
import jakarta.xml.ws.WebEndpoint; | ||
import jakarta.xml.ws.WebServiceClient; | ||
import jakarta.xml.ws.WebServiceFeature; | ||
|
||
@WebServiceClient(name = "HelloServiceService", targetNamespace = "http://com.redhat.gss.example.soap/", wsdlLocation = "HelloServiceService.wsdl") | ||
public class HelloServiceService | ||
extends Service | ||
{ | ||
|
||
private final static QName HELLOSERVICESERVICE_QNAME = new QName("http://com.redhat.gss.example.soap/", "HelloServiceService"); | ||
|
||
public HelloServiceService(URL wsdlLocation) { | ||
super(wsdlLocation, HELLOSERVICESERVICE_QNAME); | ||
} | ||
|
||
/** | ||
* | ||
* @return | ||
* returns HelloService | ||
*/ | ||
@WebEndpoint(name = "HelloServicePort") | ||
public HelloService getHelloServicePort() { | ||
return super.getPort(new QName("http://com.redhat.gss.example.soap/", "HelloServicePort"), HelloService.class); | ||
} | ||
|
||
/** | ||
* | ||
* @param features | ||
* A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. | ||
* @return | ||
* returns HelloService | ||
*/ | ||
@WebEndpoint(name = "HelloServicePort") | ||
public HelloService getHelloServicePort(WebServiceFeature... features) { | ||
return super.getPort(new QName("http://com.redhat.gss.example.soap/", "HelloServicePort"), HelloService.class, features); | ||
} | ||
|
||
} | ||
|
72 changes: 72 additions & 0 deletions
72
...tsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws4429/JBWS4429TestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jboss.test.ws.jaxws.cxf.jbws4429; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit5.ArquillianExtension; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.FileAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.wsf.test.JBossWSTest; | ||
import org.jboss.wsf.test.JBossWSTestHelper; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
|
||
@ExtendWith(ArquillianExtension.class) | ||
public class JBWS4429TestCase extends JBossWSTest { | ||
private static final String DEP = "jaxws-cxf-jbws4429"; | ||
|
||
@ArquillianResource | ||
private URL baseURL; | ||
|
||
@Deployment(name = DEP, testable = false) | ||
public static WebArchive createDeployment() { | ||
WebArchive archive = ShrinkWrap.create(WebArchive.class, DEP + ".war"); | ||
archive.setManifest(new StringAsset("Manifest-Version: 1.0\n" | ||
+ "Dependencies: org.apache.cxf org.jboss.logging \n")) | ||
.addClasses(HelloServiceImpl.class, LoggingHandler.class) | ||
.add(new FileAsset(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws4429/handlers.xml")), "WEB-INF/classes/handlers.xml") | ||
; | ||
return archive; | ||
} | ||
|
||
@Test | ||
@RunAsClient | ||
public void testWS() throws Exception { | ||
URL wsdlURL = JBWS4429TestCase.getResourceURL("/jaxws/cxf/jbws4429/WEB-INF/wsdl/HelloService.wsdl"); | ||
HelloServiceService clientService = new HelloServiceService(wsdlURL); | ||
HelloService service = clientService.getHelloServicePort(); | ||
try { | ||
service.sayHello("Jim"); | ||
Assertions.fail("sayHello() call should fail"); | ||
} catch (Exception e) { | ||
Assertions.assertEquals("JBWS024118: BindingOperation is missing for authorization", e.getMessage()); | ||
} | ||
|
||
} | ||
|
||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...estsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws4429/LoggingHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jboss.test.ws.jaxws.cxf.jbws4429; | ||
|
||
import javax.xml.namespace.QName; | ||
import jakarta.xml.ws.handler.MessageContext; | ||
import jakarta.xml.ws.handler.soap.SOAPHandler; | ||
import jakarta.xml.ws.handler.soap.SOAPMessageContext; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
public class LoggingHandler implements SOAPHandler<SOAPMessageContext> { | ||
|
||
@Override | ||
public boolean handleMessage(SOAPMessageContext soapMessageContext) { | ||
boolean isOutBound = (boolean) soapMessageContext.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY); | ||
if (isOutBound) { | ||
System.out.println("### outbound message from JBoss EAP ###"); | ||
} else { | ||
System.out.println("### inbound message from a client ###"); | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public Set<QName> getHeaders() { | ||
return Collections.emptySet(); | ||
} | ||
|
||
@Override | ||
public boolean handleFault(SOAPMessageContext soapMessageContext) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void close(MessageContext messageContext) { | ||
// no-operation | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws4429/ObjectFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.jboss.test.ws.jaxws.cxf.jbws4429; | ||
import jakarta.xml.bind.JAXBElement; | ||
import jakarta.xml.bind.annotation.XmlElementDecl; | ||
import jakarta.xml.bind.annotation.XmlRegistry; | ||
import javax.xml.namespace.QName; | ||
|
||
|
||
/** | ||
* This object contains factory methods for each | ||
* Java content interface and Java element interface | ||
* generated in the com.redhat.gss.example.soap package. | ||
* <p>An ObjectFactory allows you to programatically | ||
* construct new instances of the Java representation | ||
* for XML content. The Java representation of XML | ||
* content can consist of schema derived interfaces | ||
* and classes representing the binding of schema | ||
* type definitions, element declarations and model | ||
* groups. Factory methods for each of these are | ||
* provided in this class. | ||
* | ||
*/ | ||
@XmlRegistry | ||
public class ObjectFactory { | ||
|
||
private final static QName _SayHelloResponse_QNAME = new QName("http://com.redhat.gss.example.soap/", "sayHelloResponse"); | ||
private final static QName _SayHello_QNAME = new QName("http://com.redhat.gss.example.soap/", "sayHello"); | ||
|
||
/** | ||
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.redhat.gss.example.soap | ||
* | ||
*/ | ||
public ObjectFactory() { | ||
} | ||
|
||
/** | ||
* Create an instance of {@link SayHello } | ||
* | ||
*/ | ||
public SayHello createSayHello() { | ||
return new SayHello(); | ||
} | ||
|
||
/** | ||
* Create an instance of {@link SayHelloResponse } | ||
* | ||
*/ | ||
public SayHelloResponse createSayHelloResponse() { | ||
return new SayHelloResponse(); | ||
} | ||
|
||
/** | ||
* Create an instance of {@link JAXBElement }{@code <}{@link SayHelloResponse }{@code >}} | ||
* | ||
*/ | ||
@XmlElementDecl(namespace = "http://com.redhat.gss.example.soap/", name = "sayHelloResponse") | ||
public JAXBElement<SayHelloResponse> createSayHelloResponse(SayHelloResponse value) { | ||
return new JAXBElement<SayHelloResponse>(_SayHelloResponse_QNAME, SayHelloResponse.class, null, value); | ||
} | ||
|
||
/** | ||
* Create an instance of {@link JAXBElement }{@code <}{@link SayHello }{@code >}} | ||
* | ||
*/ | ||
@XmlElementDecl(namespace = "http://com.redhat.gss.example.soap/", name = "sayHello") | ||
public JAXBElement<SayHello> createSayHello(SayHello value) { | ||
return new JAXBElement<SayHello>(_SayHello_QNAME, SayHello.class, null, value); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can move up this stuff by 1 line? @jimma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @asoldano . This is better. I'll get this fixed in the next commit.