You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jb...@apache.org on 2009/11/21 18:17:10 UTC
svn commit: r882942 -
/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
Author: jbonofre
Date: Sat Nov 21 17:17:09 2009
New Revision: 882942
URL: http://svn.apache.org/viewvc?rev=882942&view=rev
Log:
[SMXCOMP-649] A NullPointerException is raised when the target endpoint is not found.
Modified:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=882942&r1=882941&r2=882942&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Sat Nov 21 17:17:09 2009
@@ -547,37 +547,48 @@
private void retrieveWSDL() throws JBIException, WSDLException, DeploymentException, IOException {
if (wsdl == null) {
+ ServiceEndpoint targetEndpoint = null;
+ // the user has provided the targetService and targetEndpoint attributes
if (getTargetService() != null && getTargetEndpoint() != null) {
- ServiceEndpoint serviceEndpoint
- = getServiceUnit().getComponent().getComponentContext().getEndpoint(getTargetService(), getTargetEndpoint());
- if (serviceEndpoint != null) {
- description =
- this.getServiceUnit().getComponent().getComponentContext().getEndpointDescriptor(serviceEndpoint);
- definition = getBus().getExtension(WSDLManager.class)
- .getDefinition((Element)description.getFirstChild());
- List address = definition.getService(getTargetService()).getPort(getTargetEndpoint()).getExtensibilityElements();
- if (address == null || address.size() == 0) {
- SOAPAddressImpl soapAddress = new SOAPAddressImpl();
- //specify default transport if there is no one in the internal wsdl
- soapAddress.setLocationURI("http://localhost");
- definition.getService(getTargetService()).getPort(getTargetEndpoint()).addExtensibilityElement(soapAddress);
- }
- List binding = definition.getService(getTargetService()).getPort(
- getTargetEndpoint()).getBinding().getExtensibilityElements();
- if (binding == null || binding.size() == 0) {
- //no binding info in the internal wsdl so we need add default soap11 binding
- SOAPBinding soapBinding = new SOAPBindingImpl();
- soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
- soapBinding.setStyle("document");
- definition.getService(getTargetService()).getPort(getTargetEndpoint()).getBinding().
- addExtensibilityElement(soapBinding);
- }
-
+ targetEndpoint = getServiceUnit().getComponent().getComponentContext().getEndpoint(getTargetService(), getTargetEndpoint());
+ }
+ // the user has provided only the targetService attribute
+ if (getTargetService() != null && getTargetEndpoint() == null) {
+ ServiceEndpoint[] endpoints = getServiceUnit().getComponent().getComponentContext().getEndpointsForService(getTargetService());
+ if (endpoints != null && endpoints.length > 0) {
+ targetEndpoint = endpoints[0];
+ }
+ }
+ // the user has provided only the targetInterfaceName attribute
+ if (getTargetEndpoint() == null && getTargetInterface() != null) {
+ ServiceEndpoint[] endpoints = getServiceUnit().getComponent().getComponentContext().getEndpoints(getTargetInterface());
+ if (endpoints != null && endpoints.length > 0) {
+ targetEndpoint = endpoints[0];
}
- } else {
- throw new DeploymentException("can't get wsdl");
}
+ if (targetEndpoint == null) {
+ throw new DeploymentException("The target endpoint is not found.");
+ }
+
+ description = this.getServiceUnit().getComponent().getComponentContext().getEndpointDescriptor(targetEndpoint);
+ definition = getBus().getExtension(WSDLManager.class).getDefinition((Element)description.getFirstChild());
+ List address = definition.getService(getTargetService()).getPort(getTargetEndpoint()).getExtensibilityElements();
+ if (address == null || address.size() == 0) {
+ SOAPAddressImpl soapAddress = new SOAPAddressImpl();
+ //specify default transport if there is no one in the internal wsdl
+ soapAddress.setLocationURI("http://localhost");
+ definition.getService(getTargetService()).getPort(getTargetEndpoint()).addExtensibilityElement(soapAddress);
+ }
+ List binding = definition.getService(getTargetService()).getPort(getTargetEndpoint()).getBinding().getExtensibilityElements();
+ if (binding == null || binding.size() == 0) {
+ //no binding info in the internal wsdl so we need add default soap11 binding
+ SOAPBinding soapBinding = new SOAPBindingImpl();
+ soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+ soapBinding.setStyle("document");
+ definition.getService(getTargetService()).getPort(getTargetEndpoint()).getBinding().
+ addExtensibilityElement(soapBinding);
+ }
} else {
description = DomUtil.parse(wsdl.getInputStream());
try {