Re: relative path to WSDL in CXF

2018-02-07 Thread Al Grant
Finally worked with:

@WebServiceClient(name = "SalesService", targetNamespace =
"urn:sales.test.au/schema/common", wsdlLocation =
"classpath:SalesService.wsdl")
public class SalesService
extends Service
{

private final static URL SalesSERVICE_WSDL_LOCATION;
private final static WebServiceException SalesSERVICE_EXCEPTION;
private final static QName SalesSERVICE_QNAME = new
QName("urn:sales.test.au/schema/common", "SalesService");

static {
//URL url =
SalesService.class.getClassLoader().getResource("SalesService.wsdl");
URL url = null;
WebServiceException e = null;
try {
url =
SalesService.class.getClassLoader().getResource("SalesService.wsdl"); //new
URL("SalesService.wsdl");
} catch (Exception ex) {
e = new WebServiceException(ex);
}

SalesSERVICE_WSDL_LOCATION = url;
SalesSERVICE_EXCEPTION = e;
}

Note I had to use : getClassLoader().getResource()





--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html


Re: relative path to WSDL in CXF

2018-02-07 Thread Al Grant
Hi,

This is getting very frustrating trying to get the project to find relative
paths to the WDSL.

Environment: Java 7
Build Tool: gradle
IDE: Intellij

The WSDL file runs fine in the IDE with :

@WebServiceClient(name = "SalesService", targetNamespace =
"urn:Sales.test.au/schema/common", wsdlLocation = "file:SalesService.wsdl")
public class SalesService
extends Service
{

private final static URL SalesSERVICE_WSDL_LOCATION;
private final static WebServiceException SalesSERVICE_EXCEPTION;
private final static QName SalesSERVICE_QNAME = new
QName("urn:Sales.test.au/schema/common", "SalesService");

static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("file:SalesService.wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}

But try that same code in a packaged jar and it results in a file not found
(even though the file is present in the JAR).

This post seemed to be relevant:

https://stackoverflow.com/questions/4455195/how-to-avoid-the-need-to-specify-the-wsdl-location-in-a-cxf-or-jax-ws-generated

They modified the URL in the WDSL - and found that the parameter needed to
be passed as :

@WebServiceClient(name = "SalesService", targetNamespace =
"urn:sales.test.au/schema/common", wsdlLocation =
"classpath:src/main/resources/SalesService.wsdl")
...
URL url = null;
WebServiceException e = null;
try {
url = new URL("SalesService.wsdl");

but that also fails for me (in particular on the line  url = new
URL("SalesService.wsdl");).

I also wondered if this is relevant:
https://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar

Surely this is not a new issue? What is the solution?

I have tried several "paths" now and am at a loss.

Cheers

AG





--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html


Re: Pretty Logging

2018-02-07 Thread Al Grant
This is what worked for me for the benefit of anyone else:

// LOGGING
LoggingOutInterceptor loi = new LoggingOutInterceptor();
loi.setPrettyLogging(true);
LoggingInInterceptor lii = new LoggingInInterceptor();
lii.setPrettyLogging(true);

org.apache.cxf.endpoint.Client client =
org.apache.cxf.frontend.ClientProxy.getClient(isalesService);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

cxfEndpoint.getOutInterceptors().add(loi);
cxfEndpoint.getInInterceptors().add(lii);



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html


Re: Getting an EndPoint to Add Interceptor

2018-02-07 Thread Colm O hEigeartaigh
Using the Dispatch API can be tricky. I haven't tried it with SOAPMessage,
so I'm not sure if WS-Security works there or not. I've added two examples
though to show how to use the Dispatch API with Signature using payload:

https://github.com/apache/cxf/blob/5d67785208334062a950dc7f85ffcb7d52af3db5/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java#L492

and message:

https://github.com/apache/cxf/blob/5d67785208334062a950dc7f85ffcb7d52af3db5/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java#L534

Colm.

On Tue, Feb 6, 2018 at 8:13 PM, George S.  wrote:

> Would you mind giving me a few pointers? I'm trying things out. I'm told
> (I can't run it myself) that the message is not getting signed. I'm
> probably doing something really dumb, but if you could help I would
> appreciate it. Here's my code:
>
> try  {
> MessageFactory mf = MessageFactory.newInstance();
> SOAPMessage reqMesg = mf.createMessage();
> SOAPMessage response;// = mf.createMessage();
> toSOAPElement(notifyDocketingCompleteRequest, reqMesg);
>
> String  namespace = cfgProps.getProperty("efm.namespace","");
> String  serviceName = cfgProps.getProperty("efm.serviceName","");
> String  portName = cfgProps.getProperty("efm.portName","");
> String  methodName = cfgProps.getProperty("efm.methodName.nDC","");
> String  endpointAddress = cfgProps.getProperty("efm.stag
> eEndpointAddress","");
> String  WS_URL = cfgProps.getProperty("efm.stageWS_URL","");
>
> URL wsdlLocation =new  URL(WS_URL);
> QName serviceQName =new  QName(namespace, serviceName);
> QName portQName =new  QName(namespace, portName);
>
> Service service = Service.create(wsdlLocation, serviceQName);
> PortType port=service.getPort(portQName,PortType.class);
>
> Map interceptorProperties=new  HashMap<>();
> interceptorProperties.put(WSHandlerConstants.ACTION,"Signature");
> interceptorProperties.put(WSHandlerConstants.SIG_PROP_FILE,"
> client_sign.properties");
>
> WSS4JOutInterceptor interceptor=new  WSS4JOutInterceptor(intercepto
> rProperties);
>
> Client cxfClient=ClientProxy.getClient(port);
> cxfClient.getOutInterceptors().add(interceptor);
>
> Dispatch dispatch = service.createDispatch(portQName,
> SOAPMessage.class, Service.Mode.MESSAGE);
>
> BindingProvider bp = (BindingProvider) dispatch;
> SOAPBinding binding = (SOAPBinding) bp.getBinding();
> bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> endpointAddress);
> binding.setMTOMEnabled(true);
>
> List handlerChain =new  ArrayList();
> p.ClientLogicalHandler cAuth =new  p.ClientLogicalHandler();
> p.EnvelopeLoggingSOAPHandler logging =new
> p.EnvelopeLoggingSOAPHandler();
> handlerChain.add(cAuth);
> handlerChain.add(logging);
> binding.setHandlerChain(handlerChain);
> // Put it all in the context object
> Map myContext = bp.getRequestContext();
>
> response = dispatch.invoke(reqMesg);
> ElementNSImpl myResponseElement = (ElementNSImpl)
> response.getSOAPBody();
>
> return  myResponseElement;
>
> }  catch  (SOAPException e1){
> e1.printStackTrace();
> }  catch  (SOAPFaultException e1){
> SOAPFault fault = e1.getFault();
> e1.printStackTrace();
> return  fault;
> }  catch  (Exception wse){
> String  errResponse = wse.getMessage();
> wse.printStackTrace();
> System.out.println(wse);
> Object  response = errResponse;
> return  response;
> }
>
>
> On 2/2/2018 2:55 AM, Colm O hEigeartaigh wrote:
>
>> If you want to add an interceptor on the client side, you can do something
>> like:
>>
>> Service service = Service.create(wsdlLocation, serviceQName);
>> PortType port = service.getPort(portQName, PortType.class);
>> Client cxfClient = ClientProxy.getClient(port);
>> cxfClient.getOutInterceptors().add(...)
>>
>> Here's an example:
>>
>> https://github.com/apache/cxf/blob/dcae47fac2c0e22994572e674
>> 4852070737223e5/systests/ws-security/src/test/java/org/apach
>> e/cxf/systest/ws/ut/UsernameTokenTest.java#L439
>>
>> Colm.
>>
>> On Thu, Feb 1, 2018 at 9:07 PM, George S.  wrote:
>>
>> I apologize for the really basic level of my question. I've looked at the
>>> docs and I'm really not figuring out how to do this. I'm adapting some
>>> code:
>>>
>>> import javax.xml.ws.Service;
>>>
>>> URL wsdlLocation =new  URL(WS_URL);
>>> QName serviceQName =new  QName(namespace, serviceName);
>>> QName portQName =new  QName(namespace, portName);
>>> Service service = Service.create(wsdlLocation, serviceQName);
>>>
>>> and I'm desperately trying to figure out how to get an Endpoint so I can
>>> add an Interceptor. If I have the service ( which from looking at the
>>> code
>>> for javax.xml.ws.Service is created by a Provider()), how can I get to
>>> the
>>> endpoint?
>>>
>>> I've looked at:
>>>
>>> 

Re: Support tomcat 9 with osgi

2018-02-07 Thread Andy McCright
Hi Arnaud,

This seems like an oversight to me.  Can you open an issue on the JIRA site
[1]?

In Liberty, we test CXF 3.2.X with Servlet 4.0, but we also repackage the
modules which ends up re-writing the bundle manifests.  I think we can make
this work for everybody by incrementing the Import-Package version for the
javax.servlet packages to include 4.0 (i.e. "[0,4.1)" - it is currently set
to "[0,4.0)".

Thanks for reporting this,

Andy

[1] https://issues.apache.org/jira/projects/CXF/issues

On Wed, Feb 7, 2018 at 4:00 AM, Arnaud Yahoo 
wrote:

> Hello,
>
> Osgi application using cxf cannot be deployed on tomcat 9 because osgi
> manifest exclude servlet 4.0. Are there any reasons for that ?
>
> Are there any plan to support Servlet 4.0 api ?
>
> Regards,
>
> Arnaud
>
>


Support tomcat 9 with osgi

2018-02-07 Thread Arnaud Yahoo

Hello,

Osgi application using cxf cannot be deployed on tomcat 9 because osgi 
manifest exclude servlet 4.0. Are there any reasons for that ?


Are there any plan to support Servlet 4.0 api ?

Regards,

Arnaud



Re: Pretty Logging

2018-02-07 Thread Al Grant
I do actually get the message on the console, but its all run together, no
new lines or indentation.

Is that what the pretty part would do if i had it going?





--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html