You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Red Eagle <x....@gmail.com> on 2008/03/21 13:37:22 UTC
Setting direct Endpoint URL
Hi @ all
I want to communicate with an web service which doesn't provide an wsdl
file. For generating the java classes I took an wsdl file from my file
system.
So far so good.
I successfully implemented an client which talks to the server but the
client takes the wsdl file. So I tried to set the Endpoint URL directly
with the method addPort but always an exception occurred that the wsdl
file wasn't found.
I looked into the generated service class and saw that he needs an wsdl
file, so my question is if it is possible to switch this behaviour off.
regars
Re: Setting direct Endpoint URL
Posted by Red Eagle <x....@gmail.com>.
Hi again,
I tried your code snippet and played around with it, but i'm always
getting a NullPointerException when the getPort method is called (see
below).
java.lang.NullPointerException
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPortModel(Unknown
Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown
Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(Unknown
Source)
at javax.xml.ws.Service.getPort(Unknown Source)
Do you you have any idea how i can solve this problem?
Steve
Daniel Kulp schrieb:
> Ooopss. Missed a line in there:
>
> QName portName = new QName("http://the.name.space",
> "MyPort");
> QName servName = new QName("http://the.name.space",
> "MyService");
>
> Service service = Service.create(servName);
> service.addPort(portName,
> SOAPBinding.SOAP11HTTP_BINDING,
> address);
> MyPortType port = service.getPort(portName, MyPortType.class);
>
>
> Dan
>
>
> On Friday 21 March 2008, Daniel Kulp wrote:
>
>> On Friday 21 March 2008, Red Eagle wrote:
>>
>>> Thanks for your fast reply,
>>>
>>> I tried your solution but i'm always getting an null pointer
>>> exception we because service.getPort returns it. I used wsdl2java to
>>> generate all the jaxb classes.
>>> Can you give me a hint how i can solve this null pointer problem
>>>
>> The easiest way may be to just throw out the generated Service class
>> (just use the interface and types) via:
>>
>>
>>
>>
>> QName portName = new QName("http://the.name.space",
>> "MyPort");
>> QName servName = new QName("http://the.name.space",
>> "MyService");
>>
>> Service service = Service.create(servName);
>> MyPortType port = service.getPort(portName, MyPortType.class);
>> ((BindingProvider)port).get.........
>>
>> Dan
>>
>>
>>> regards
>>>
>>> Daniel Kulp schrieb:
>>>
>>>> On Friday 21 March 2008, Red Eagle wrote:
>>>>
>>>>> I want to communicate with an web service which doesn't provide
>>>>> an wsdl file. For generating the java classes I took an wsdl file
>>>>> from my file system.
>>>>> So far so good.
>>>>>
>>>>> I successfully implemented an client which talks to the server
>>>>> but the client takes the wsdl file. So I tried to set the
>>>>> Endpoint URL directly with the method addPort but always an
>>>>> exception occurred that the wsdl file wasn't found.
>>>>>
>>>>> I looked into the generated service class and saw that he needs
>>>>> an wsdl file, so my question is if it is possible to switch this
>>>>> behaviour off.
>>>>>
>>>> Yep. You can pass in null for the wsdl url and just rely on the
>>>> annotations for formatting the message. That's perfectly fine.
>>>> The issue is how to set the URL that the endpoint then hits.
>>>> The spec does allow for this via the BindingProvider:
>>>>
>>>> MyThing port = service.getPort(....);
>>>> ((BindingProvider)port).getRequestContext().put(
>>>> BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
>>>>
>
>
>
>
Re: Setting direct Endpoint URL
Posted by Daniel Kulp <dk...@apache.org>.
Ooopss. Missed a line in there:
QName portName = new QName("http://the.name.space",
"MyPort");
QName servName = new QName("http://the.name.space",
"MyService");
Service service = Service.create(servName);
service.addPort(portName,
SOAPBinding.SOAP11HTTP_BINDING,
address);
MyPortType port = service.getPort(portName, MyPortType.class);
Dan
On Friday 21 March 2008, Daniel Kulp wrote:
> On Friday 21 March 2008, Red Eagle wrote:
> > Thanks for your fast reply,
> >
> > I tried your solution but i'm always getting an null pointer
> > exception we because service.getPort returns it. I used wsdl2java to
> > generate all the jaxb classes.
> > Can you give me a hint how i can solve this null pointer problem
>
> The easiest way may be to just throw out the generated Service class
> (just use the interface and types) via:
>
>
>
>
> QName portName = new QName("http://the.name.space",
> "MyPort");
> QName servName = new QName("http://the.name.space",
> "MyService");
>
> Service service = Service.create(servName);
> MyPortType port = service.getPort(portName, MyPortType.class);
> ((BindingProvider)port).get.........
>
> Dan
>
> > regards
> >
> > Daniel Kulp schrieb:
> > > On Friday 21 March 2008, Red Eagle wrote:
> > >> I want to communicate with an web service which doesn't provide
> > >> an wsdl file. For generating the java classes I took an wsdl file
> > >> from my file system.
> > >> So far so good.
> > >>
> > >> I successfully implemented an client which talks to the server
> > >> but the client takes the wsdl file. So I tried to set the
> > >> Endpoint URL directly with the method addPort but always an
> > >> exception occurred that the wsdl file wasn't found.
> > >>
> > >> I looked into the generated service class and saw that he needs
> > >> an wsdl file, so my question is if it is possible to switch this
> > >> behaviour off.
> > >
> > > Yep. You can pass in null for the wsdl url and just rely on the
> > > annotations for formatting the message. That's perfectly fine.
> > > The issue is how to set the URL that the endpoint then hits.
> > > The spec does allow for this via the BindingProvider:
> > >
> > > MyThing port = service.getPort(....);
> > > ((BindingProvider)port).getRequestContext().put(
> > > BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog
Re: Setting direct Endpoint URL
Posted by Daniel Kulp <dk...@apache.org>.
On Friday 21 March 2008, Red Eagle wrote:
> Thanks for your fast reply,
>
> I tried your solution but i'm always getting an null pointer exception
> we because service.getPort returns it. I used wsdl2java to generate
> all the jaxb classes.
> Can you give me a hint how i can solve this null pointer problem
The easiest way may be to just throw out the generated Service class
(just use the interface and types) via:
QName portName = new QName("http://the.name.space",
"MyPort");
QName servName = new QName("http://the.name.space",
"MyService");
Service service = Service.create(servName);
MyPortType port = service.getPort(portName, MyPortType.class);
((BindingProvider)port).get.........
Dan
> regards
>
> Daniel Kulp schrieb:
> > On Friday 21 March 2008, Red Eagle wrote:
> >> I want to communicate with an web service which doesn't provide an
> >> wsdl file. For generating the java classes I took an wsdl file from
> >> my file system.
> >> So far so good.
> >>
> >> I successfully implemented an client which talks to the server but
> >> the client takes the wsdl file. So I tried to set the Endpoint URL
> >> directly with the method addPort but always an exception occurred
> >> that the wsdl file wasn't found.
> >>
> >> I looked into the generated service class and saw that he needs an
> >> wsdl file, so my question is if it is possible to switch this
> >> behaviour off.
> >
> > Yep. You can pass in null for the wsdl url and just rely on the
> > annotations for formatting the message. That's perfectly fine.
> > The issue is how to set the URL that the endpoint then hits. The
> > spec does allow for this via the BindingProvider:
> >
> > MyThing port = service.getPort(....);
> > ((BindingProvider)port).getRequestContext().put(
> > BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog
Re: Setting direct Endpoint URL
Posted by Red Eagle <x....@gmail.com>.
Thanks for your fast reply,
I tried your solution but i'm always getting an null pointer exception
we because service.getPort returns it. I used wsdl2java to generate all
the jaxb classes.
Can you give me a hint how i can solve this null pointer problem
regards
Daniel Kulp schrieb:
> On Friday 21 March 2008, Red Eagle wrote:
>
>> I want to communicate with an web service which doesn't provide an
>> wsdl file. For generating the java classes I took an wsdl file from my
>> file system.
>> So far so good.
>>
>> I successfully implemented an client which talks to the server but the
>> client takes the wsdl file. So I tried to set the Endpoint URL
>> directly with the method addPort but always an exception occurred that
>> the wsdl file wasn't found.
>>
>> I looked into the generated service class and saw that he needs an
>> wsdl file, so my question is if it is possible to switch this
>> behaviour off.
>>
>
> Yep. You can pass in null for the wsdl url and just rely on the
> annotations for formatting the message. That's perfectly fine. The
> issue is how to set the URL that the endpoint then hits. The spec
> does allow for this via the BindingProvider:
>
> MyThing port = service.getPort(....);
> ((BindingProvider)port).getRequestContext().put(
> BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
>
>
>
>
Re: Setting direct Endpoint URL
Posted by Daniel Kulp <dk...@apache.org>.
On Friday 21 March 2008, Red Eagle wrote:
> I want to communicate with an web service which doesn't provide an
> wsdl file. For generating the java classes I took an wsdl file from my
> file system.
> So far so good.
>
> I successfully implemented an client which talks to the server but the
> client takes the wsdl file. So I tried to set the Endpoint URL
> directly with the method addPort but always an exception occurred that
> the wsdl file wasn't found.
>
> I looked into the generated service class and saw that he needs an
> wsdl file, so my question is if it is possible to switch this
> behaviour off.
Yep. You can pass in null for the wsdl url and just rely on the
annotations for formatting the message. That's perfectly fine. The
issue is how to set the URL that the endpoint then hits. The spec
does allow for this via the BindingProvider:
MyThing port = service.getPort(....);
((BindingProvider)port).getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog