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:[EMAIL PROTECTED]
Sent: Wednesday, December 06, 2006 11:34 PM
To: [email protected]
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:[EMAIL PROTECTED]
Sent: Wednesday, December 06, 2006 1:20 PM
To: [email protected]
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?