On Apr 29, 2014, at 2:23 AM, Andrei Shakirin <[email protected]> wrote:
> Hi,
>
> Yes, one option is using with Dispatch interface and don't touch JAXB at all.
> You will need two things:
>
> a) set the required parameters (keystores, callbacks) on the request context;
> b) parse your policy with Neethi and set it using POLICY_OVERRIDE property in
> request context (see my blog [1] for details)
Actually, you shouldn’t need (b) at all. If you create the Dispatch using the
wsdl that has the policies and then set the WSDL_OPERATION (it’s a QName) to
the appropriate Operation defined in the WSDL, then the policies and such found
in the WSDL should take effect.
Dan
>
> The second option is use DynamicClientFactory, the code will look like:
>
> DynamicClientFactory dcf = DynamicClientFactory.newInstance();
> Client client = dcf.createClient(wsdlLocation);
> SourceDataBinding sdb = new SourceDataBinding(StreamSource.class);
> client.getEndpoint().getService().setDataBinding(sdb);
> StreamSource request = new
> StreamSource(ServiceUtils.class.getResourceAsStream("/seekBookResponse.xml"));
> Object[] response = client.invoke(operationName, request);
>
> The first option is more flexible and generic, the second one is easy to
> implement.
>
> Regards,
> Andrei.
>
> [1] http://ashakirin.blogspot.de/2012/02/using-ws-policy-in-cxf-projects.html
>
>> -----Original Message-----
>> From: Joel Pearson [mailto:[email protected]]
>> Sent: Freitag, 25. April 2014 07:05
>> To: [email protected]
>> Subject: Re: Possible to use arbitrary xml with a JAX-WS client and JAXB?
>>
>> Hi Andrei,
>>
>> I did forget to mention that I wanted to send an arbitrary xml as the body,
>> but I
>> still wanted ws policy to apply to the security header.
>>
>> So I presume if I create a service the usual way that includes the WSDL with
>> the
>> WS-Policy, createDispatch like you mentioned then I can just set all the
>> required variables (keystores and such) on the request context as I would
>> normally with the port interface with the client classes?
>>
>> So you're saying that I shouldn't need to deal with JAXB at all?
>>
>> I can't get to my pc for a few days which is why I haven't tried it yet.
>>
>> Thanks,
>>
>> Joel
>>
>> On Friday, April 25, 2014, Andrei Shakirin [via CXF] <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> I am not sure that I understand your use case.
>>> If you would like just to send arbitrary xml to the web service,
>>> Dispatch interface is exactly what you need.
>>>
>>> The code will look like:
>>> Service service = Service.create(SERVICE_NAME);
>>> service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING,
>>> ADDRESS);
>>>
>>> Dispatch<Source> dispatch = service.createDispatch(PORT_NAME,
>>> Source.class, Service.Mode.PAYLOAD);
>>>
>>> System.out.println("Invoking sayHi...");
>>>
>>> dispatch.getRequestContext().put(MessageContext.WSDL_OPERATION,
>>> operationName);
>>> Source response = dispatch.invoke(new StreamSource(new
>>> ByteArrayInputStream(payload.getBytes("utf-8"))));
>>>
>>> Take a look into jaxws_dispatch_provider delivered with CXF for details.
>>>
>>> Regards,
>>> Andrei.
>>>
>>>> -----Original Message-----
>>>> From: bimjoeipa [mailto:[hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=5743257&i=0>]
>>>
>>>> Sent: Donnerstag, 24. April 2014 09:53
>>>> To: [hidden
>>>> email]<http://user/SendEmail.jtp?type=node&node=5743257&i=1>
>>>> Subject: Possible to use arbitrary xml with a JAX-WS client and JAXB?
>>>>
>>>> Hi,
>>>>
>>>> I'm trying to figure out if a workaround is feasible.
>>>>
>>>> I want to have the ability to have have arbitrary xml and map that
>>>> to
>>> some
>>>> generated JAX-WS Client classes and then invoke it as a regular service.
>>>>
>>>> I've been able to use JAXB to map the xml string into Request
>>>> Wrapper
>>> objects
>>>> generated by XJC (using the maven cxf plugin), however I don't know
>>>> what
>>> to
>>>> do with the request wrapper object, because normally you'd invoke
>>>> the WebMethod from the Service Interface. But in my case I want to
>>>> invoke
>>> the
>>>> service using the request wrapper. Is this possible?
>>>>
>>>> I had a look at what methods were available on the Service, and I
>>>> found
>>> you can
>>>> create a Dispatch Object from a JAXBContext, but I couldn't figure
>>>> out
>>> how that
>>>> is supposed to be used.
>>>>
>>>> I realise what I'm doing is probably a non-standard usage of the
>>>> JAX-WS
>>> api, but
>>>> it is it possible with CXF somehow?
>>>>
>>>> Thanks,
>>>>
>>>> Joel
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>> http://cxf.547215.n5.nabble.com/Possible-to-use-
>>>> arbitrary-xml-with-a-JAX-WS-client-and-JAXB-tp5743219.html
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>>
>>> ------------------------------
>>> If you reply to this email, your message will be added to the
>>> discussion
>>> below:
>>>
>>> http://cxf.547215.n5.nabble.com/Possible-to-use-arbitrary-xml-with-a-J
>>> AX-WS-client-and-JAXB-tp5743219p5743257.html
>>> To unsubscribe from Possible to use arbitrary xml with a JAX-WS
>>> client and JAXB?, click
>>> here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=un
>>>
>> subscribe_by_code&node=5743219&code=am9lbC5wZWFyc29uQGdtYWlsLmNv
>> bXw1Nz
>>> QzMjE5fDY2MDI1MDExMw==>
>>> .
>>>
>> NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=ma
>>>
>> cro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.na
>> me
>>> spaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-
>> nabble.
>>>
>> view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nab
>> bl
>>> e%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-
>> send_instant_email
>>> %21nabble%3Aemail.naml>
>>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/Possible-to-use-
>> arbitrary-xml-with-a-JAX-WS-client-and-JAXB-tp5743219p5743278.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
--
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com