You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Dan Diephouse <da...@envoisolutions.com> on 2006/12/11 11:57:24 UTC

CodeFirstTest [was Re: FW: Java first question]

Hi Willem,

Sorry for the delayed response. Can you explain more what you mean or give
an example? I'm not sure I understand.
Thanks,
- Dan

On 12/7/06, Willem Jiang <ni...@iona.com> wrote:
>
> Hi Eric and Dan,
>
> I wrote a unit test in the CodeFirstTest, and found that in code first
> mode the client side can't deal with the complex type result or
> parameters' marshal and unmarshal.
>
> Eric , IMO the WSDL first option could be the best solution.
>
> Dan , I have no ideal about how to build up the type info (for XML
> marshal an unmarshal) in the parameters without read annotation from
> SEI, Can you point it out?
>
> Cheers,
>
> Willem.
>
> Johnson, Eric wrote:
>
> >Willem,
> >Thanks for the help. I'll give it a go in the morning!!
> >Cheers,
> >Eric
> >
> >
> >
> >>-----Original Message-----
> >>From: Willem Jiang [mailto:ning.jiang@iona.com]
> >>Sent: Wednesday, December 06, 2006 11:34 PM
> >>To: cxf-dev@incubator.apache.org
> >>Subject: Re: FW: Java first question
> >>
> >>Hi Eric,
> >>
> >>I think your client side code need to be changed to get the
> >>connect to the server.
> >>Here are two ways to create client.
> >>
> >>1.  Code first , as you know , when you use code first to
> >>create webservice, you need to specify the endpoint address
> >>or the ServerFactoryBean will build an default address for you.
> >>     That means from the Java code we can't get the address
> >>to build up the endpoint information.
> >>     So when you use
> >>     Service s = Service.create(serviceName);
> >>     to create endpoint info, you can use  addport to specify
> >>the detail binding and address info.
> >>     service.addPort(portName, "http://schemas.xmlsoap.org/soap/",
> >>                        "http://localhost:9000/SoapContext/SoapPort");
> >>     quoteReporter proxy = s.getPort(portName, quoteReporter.class);
> >>    The example you can find from
> >>org.apache.cxf.systest.jaxws.ClientServerTest's testAddPort.
> >>
> >>2.  WSDL first, if you alread get the wsdl file, you just can use
> >>     Service s = Service.create(wsdlURL, servcieName);
> >>     QName portName = new QName("http://demo.eric.org",
> >>"stockQuoteReporterPort");
> >>     quoteReporter proxy = s.getPort(portName);
> >>
> >>Thanks,
> >>
> >>Willem.
> >>
> >>Johnson, Eric wrote:
> >>
> >>
> >>
> >>>
> >>>
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Johnson, Eric [mailto:Eric.Johnson@iona.com]
> >>>>Sent: Wednesday, December 06, 2006 1:20 PM
> >>>>To: cxf-dev@incubator.apache.org
> >>>>Subject: RE: FW: Java first question
> >>>>
> >>>>I got the server running and now I created the following
> >>>>
> >>>>
> >>client code
> >>
> >>
> >>>>to connect to it:
> >>>>package org.eric.demo;
> >>>>
> >>>>import java.io.File;
> >>>>import java.net.URL;
> >>>>import javax.xml.namespace.QName;
> >>>>import javax.xml.ws.Service;
> >>>>
> >>>>public class Client
> >>>>{
> >>>>public static void main(String args[])
> >>>> {
> >>>>   QName serviceName = new QName("http://demo.eric.org",
> >>>>"stockQuoteReporter");
> >>>>   Service s = Service.create(serviceName);
> >>>>    System.out.println("Service "+serviceName+" created...");
> >>>>    quoteReporter proxy = s.getPort(quoteReporter.class);
> >>>>    System.out.println("Proxy created...");
> >>>>    Quote quote = proxy.getQuote("ALPHA");
> >>>>    System.out.println("Stock "+quote.getID()+" is worth
> >>>>"+quote.getVal()+" as of "+quote.getTime());
> >>>> }
> >>>>}
> >>>>
> >>>>The SEI is as follows:
> >>>>package org.eric.demo;
> >>>>
> >>>>import javax.jws.*;
> >>>>
> >>>>@WebService(name="quoteReporter")
> >>>>public interface quoteReporter
> >>>>{
> >>>> public Quote getQuote(String ticker); }
> >>>>
> >>>>When I run the client I get the following:
> >>>>client:
> >>>>    [java] Service {http://demo.eric.org}stockQuoteReporter
> >>>>created...
> >>>>    [java] Exception in thread "main"
> >>>>javax.xml.ws.WebServiceException:
> >>>>Unable to determine port name.
> >>>>    [java]     at
> >>>>org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:267)
> >>>>    [java]     at
> >>>>org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:193)
> >>>>    [java]     at javax.xml.ws.Service.getPort(Service.java:120)
> >>>>    [java]     at org.eric.demo.Client.main(Client.java:15)
> >>>>
> >>>>What do I need to do to get the client to connect?
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>
> >>
> >
> >
> >
>
>


-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: CodeFirstTest [was Re: FW: Java first question]

Posted by Willem Jiang <ni...@iona.com>.
Hi Dan,

That comes to my question. If there are some complex types used in SEI's 
method, and they can not be handled by JAXB by default. 
How can  we  make sure the JAXB can make the xml marshal and unmarshal 
right without get the type info from the SEI's annotation?

Willem.

Dan Diephouse wrote:

> No, JAXB can't deal with List<String> - but you can make it work. I 
> managed
> to have it working at one point. Its a hack. You need to convert it to an
> array and tell JAXB that the type class is String[]. I will look at 
> the test
> and see if I can get it working again...
>
> - Dan
>
> On 12/12/06, Willem Jiang <ni...@iona.com> wrote:
>
>>
>> Hi Dan,
>>
>> You can take a look at the test which I add for the CodeFirstTest client
>> side test.
>> It is org.apache.cxf.jaxws.CodeFirstTest.testClient(), I commented the
>> last 2 line codes which can not work yet.
>> AFAIK, JAXB can't deal with the List<string> as default.
>> Can you point out what else I should do to make the test work?
>>
>> Regards,
>>
>> Willem.
>>
>> Dan Diephouse wrote:
>>
>> > Hi Willem,
>> >
>> > Sorry for the delayed response. Can you explain more what you mean or
>> > give
>> > an example? I'm not sure I understand.
>> > Thanks,
>> > - Dan
>> >
>> > On 12/7/06, Willem Jiang <ni...@iona.com> wrote:
>> >
>> >>
>> >> Hi Eric and Dan,
>> >>
>> >> I wrote a unit test in the CodeFirstTest, and found that in code 
>> first
>> >> mode the client side can't deal with the complex type result or
>> >> parameters' marshal and unmarshal.
>> >>
>> >> Eric , IMO the WSDL first option could be the best solution.
>> >>
>> >> Dan , I have no ideal about how to build up the type info (for XML
>> >> marshal an unmarshal) in the parameters without read annotation from
>> >> SEI, Can you point it out?
>> >>
>> >> Cheers,
>> >>
>> >> Willem.
>> >>
>>
>>
>
>


Re: CodeFirstTest [was Re: FW: Java first question]

Posted by Dan Diephouse <da...@envoisolutions.com>.
No, JAXB can't deal with List<String> - but you can make it work. I managed
to have it working at one point. Its a hack. You need to convert it to an
array and tell JAXB that the type class is String[]. I will look at the test
and see if I can get it working again...

- Dan

On 12/12/06, Willem Jiang <ni...@iona.com> wrote:
>
> Hi Dan,
>
> You can take a look at the test which I add for the CodeFirstTest client
> side test.
> It is org.apache.cxf.jaxws.CodeFirstTest.testClient(), I commented the
> last 2 line codes which can not work yet.
> AFAIK, JAXB can't deal with the List<string> as default.
> Can you point out what else I should do to make the test work?
>
> Regards,
>
> Willem.
>
> Dan Diephouse wrote:
>
> > Hi Willem,
> >
> > Sorry for the delayed response. Can you explain more what you mean or
> > give
> > an example? I'm not sure I understand.
> > Thanks,
> > - Dan
> >
> > On 12/7/06, Willem Jiang <ni...@iona.com> wrote:
> >
> >>
> >> Hi Eric and Dan,
> >>
> >> I wrote a unit test in the CodeFirstTest, and found that in code first
> >> mode the client side can't deal with the complex type result or
> >> parameters' marshal and unmarshal.
> >>
> >> Eric , IMO the WSDL first option could be the best solution.
> >>
> >> Dan , I have no ideal about how to build up the type info (for XML
> >> marshal an unmarshal) in the parameters without read annotation from
> >> SEI, Can you point it out?
> >>
> >> Cheers,
> >>
> >> Willem.
> >>
>
>


-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: CodeFirstTest [was Re: FW: Java first question]

Posted by Willem Jiang <ni...@iona.com>.
Hi Dan,

You can take a look at the test which I add for the CodeFirstTest client 
side test.
It is org.apache.cxf.jaxws.CodeFirstTest.testClient(), I commented the 
last 2 line codes which can not work yet.
AFAIK, JAXB can't deal with the List<string> as default. 
Can you point out what else I should do to make the test work?

Regards,

Willem.

Dan Diephouse wrote:

> Hi Willem,
>
> Sorry for the delayed response. Can you explain more what you mean or 
> give
> an example? I'm not sure I understand.
> Thanks,
> - Dan
>
> On 12/7/06, Willem Jiang <ni...@iona.com> wrote:
>
>>
>> Hi Eric and Dan,
>>
>> I wrote a unit test in the CodeFirstTest, and found that in code first
>> mode the client side can't deal with the complex type result or
>> parameters' marshal and unmarshal.
>>
>> Eric , IMO the WSDL first option could be the best solution.
>>
>> Dan , I have no ideal about how to build up the type info (for XML
>> marshal an unmarshal) in the parameters without read annotation from
>> SEI, Can you point it out?
>>
>> Cheers,
>>
>> Willem.
>>