You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by doug <do...@gmail.com> on 2007/08/23 09:37:09 UTC

Re: CXF client applet port initialization problems

Hi again,

this is sort of a progress report with a question.
Originally my client started out as:

> > >>> I used the following client side code (both the client and server
> > >>> side service code were generated from wsdl2java):
> > >>>
> > >>> 	serviceAddress = "http://" + (String)configOpts.get("hostName") +
> > >>> ":" + (String)configOpts.get("port") + serviceURI +"?wsdl";
> > >>> 	// i.e. http://192.168.98.46:8080/pfc/services/PfC?wsdl
> > >>> 	URL url = new URL(serviceAddress);
> > >>> 	QName SERVICE = new QName("urn:srv", "PfCService");
> > >>> 	PfCService service = new PfCService(url, SERVICE );
> > >>> 	PfC pfc = service.getPfC();

but it turned out after changing the SERVICE QName to:

> > QName SERVICE = new QName("http://impl.serbices.servlet.pfc.mmsn.net.au/
> > ", "PfCServicesImplService");

that I got the exception:


> javax.xml.ws.WebServiceException: Port {urn:srv}PfC not found.


which was thrown by 

  org.apache.cxf.jaxws.ServiceImpl.getPort(QName portName, Class<T> type)
 
- in particular the lines:  
     
   if (!ports.contains(portName) && !portInfos.containsKey(portName)) {
            throw new WebServiceException(new Message(
		"INVALID_PORT", BUNDLE, portName).toString());
   }

because ports and portInfos don't contain the relevant portName.
The debugger says they actually contain the port QName key:

QName("http://impl.serbices.servlet.pfc.mmsn.net.au/", "PfCServicesImplPort");

i.e. suffixed by Port instead of Service

so I modified my original client code to say:
	QName SERVICE = new 
QName("http://impl.serbices.servlet.pfc.mmsn.net.au/", "PfCServicesImplService");
	PfC_Service service = new PfC_Service(url, SERVICE );

	QName SERVICE2 = new 
QName("http://impl.serbices.servlet.pfc.mmsn.net.au/", "PfCServicesImplPort");
	pfc = (PfC)service.getPort(SERVICE2, PfC.class);

and now it seems to work. Yay!
But it wasn't exactly intuitive.


It seemed to me that the QNames could be abbreviated somewhat if I rewrote the
wsdl namespace service and port in the beans.xml file as described here in
"configuring an endpoint":
 http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html

Unfortunately when I try to set a portName, it seems to be unsupported
and when I try to set a serviceName, the format seems to be incorrect.
I was trying to do something like this:
 
  <jaxws:endpoint 
    id="PfC" 
    implementor="au.net.mmsn.pfc.servlet.serbices.impl.PfCServicesImpl" 
    address="/PfC" 
    serviceName="{urn:srv}PfC"
    portName="{urn:srv}PfC"
     />

Am I barking up the wrong tree again?
Thanks for any advice.
Doug


> On Wednesday 22 August 2007 14:11, Willem Jiang wrote:
> > The Service QName should be
> >
> > QName SERVICE = new QName("http://impl.serbices.servlet.pfc.mmsn.net.au/
> > ", "PfCServicesImplService");
> >
> >
> > Willem.
> >
> > doug wrote:
> > > I get the following WSDL, but I am not sure exactly what the Service
> > > QName should be trying to match.
> > > Thanks
> > > Doug
> > >
> > > <wsdl:definitions name="PfCServicesImplService"
> > > targetNamespace="http://impl.serbices.servlet.pfc.mmsn.net.au/">
> > >  <wsdl:import
> > > location="http://192.168.98.46:8080/pfc/services/PfC?wsdl=PfC.wsdl"
> > > namespace="urn:srv"/>
> > > <wsdl:binding name="PfCServicesImplServiceSoapBinding" type="ns1:PfC">
> > >    <soap:binding style="document"
> > >       transport="http://schemas.xmlsoap.org/soap/http"/>
> > >   <wsdl:operation name="getApplicationPushletIDs">
> > >      <soap:operation soapAction="" style="document"/>
> > >
> > >      [snip]
> > >
> > > </wsdl:binding>
> > > <wsdl:service name="PfCServicesImplService">
> > > <wsdl:port binding="ns2:PfCServicesImplServiceSoapBinding"
> > > name="PfCServicesImplPort">
> > > <soap:address location="http://192.168.98.46:8080/pfc/services/PfC"/>
> > > </wsdl:port>
> > > </wsdl:service>
> > > </wsdl:definitions>
> > >

RE: CXF client applet port initialization problems

Posted by Christopher Moesel <Ch...@avid.com>.
Hi Doug,

Unfortunately, the documentation is wrong in two respects:

(1) It doesn't appear that the jaxws:endpoint element supports a nested
portName element.  So... for now... you won't be able to specify
portName there.

(2) Although it *does* support serviceName, the format for specifying
the namespace in the docs is wrong.  I think you really want to try
something more like this:

  <jaxws:endpoint xmlns:ns1="urn:srv" 
    id="PfC" 
    implementor="au.net.mmsn.pfc.servlet.serbices.impl.PfCServicesImpl" 
    address="/PfC" 
    serviceName="ns1:PfC"
     />

Of course, if you prefer, you can declare your namespace
(xmlns:ns1="urn:srv") in a higher level element (like the spring beans
element) instead.

-Chris

-----Original Message-----
From: doug [mailto:doug.duboulay@gmail.com] 
Sent: Thursday, August 23, 2007 3:37 AM
To: cxf-user@incubator.apache.org
Subject: Re: CXF client applet port initialization problems

Hi again,

this is sort of a progress report with a question.
Originally my client started out as:

> > >>> I used the following client side code (both the client and
server
> > >>> side service code were generated from wsdl2java):
> > >>>
> > >>> 	serviceAddress = "http://" +
(String)configOpts.get("hostName") +
> > >>> ":" + (String)configOpts.get("port") + serviceURI +"?wsdl";
> > >>> 	// i.e. http://192.168.98.46:8080/pfc/services/PfC?wsdl
> > >>> 	URL url = new URL(serviceAddress);
> > >>> 	QName SERVICE = new QName("urn:srv", "PfCService");
> > >>> 	PfCService service = new PfCService(url, SERVICE );
> > >>> 	PfC pfc = service.getPfC();

but it turned out after changing the SERVICE QName to:

> > QName SERVICE = new
QName("http://impl.serbices.servlet.pfc.mmsn.net.au/
> > ", "PfCServicesImplService");

that I got the exception:


> javax.xml.ws.WebServiceException: Port {urn:srv}PfC not found.


which was thrown by 

  org.apache.cxf.jaxws.ServiceImpl.getPort(QName portName, Class<T>
type)
 
- in particular the lines:  
     
   if (!ports.contains(portName) && !portInfos.containsKey(portName)) {
            throw new WebServiceException(new Message(
		"INVALID_PORT", BUNDLE, portName).toString());
   }

because ports and portInfos don't contain the relevant portName.
The debugger says they actually contain the port QName key:

QName("http://impl.serbices.servlet.pfc.mmsn.net.au/",
"PfCServicesImplPort");

i.e. suffixed by Port instead of Service

so I modified my original client code to say:
	QName SERVICE = new 
QName("http://impl.serbices.servlet.pfc.mmsn.net.au/",
"PfCServicesImplService");
	PfC_Service service = new PfC_Service(url, SERVICE );

	QName SERVICE2 = new 
QName("http://impl.serbices.servlet.pfc.mmsn.net.au/",
"PfCServicesImplPort");
	pfc = (PfC)service.getPort(SERVICE2, PfC.class);

and now it seems to work. Yay!
But it wasn't exactly intuitive.


It seemed to me that the QNames could be abbreviated somewhat if I
rewrote the
wsdl namespace service and port in the beans.xml file as described here
in
"configuring an endpoint":
 http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html

Unfortunately when I try to set a portName, it seems to be unsupported
and when I try to set a serviceName, the format seems to be incorrect.
I was trying to do something like this:
 
  <jaxws:endpoint 
    id="PfC" 
    implementor="au.net.mmsn.pfc.servlet.serbices.impl.PfCServicesImpl" 
    address="/PfC" 
    serviceName="{urn:srv}PfC"
    portName="{urn:srv}PfC"
     />

Am I barking up the wrong tree again?
Thanks for any advice.
Doug


> On Wednesday 22 August 2007 14:11, Willem Jiang wrote:
> > The Service QName should be
> >
> > QName SERVICE = new
QName("http://impl.serbices.servlet.pfc.mmsn.net.au/
> > ", "PfCServicesImplService");
> >
> >
> > Willem.
> >
> > doug wrote:
> > > I get the following WSDL, but I am not sure exactly what the
Service
> > > QName should be trying to match.
> > > Thanks
> > > Doug
> > >
> > > <wsdl:definitions name="PfCServicesImplService"
> > > targetNamespace="http://impl.serbices.servlet.pfc.mmsn.net.au/">
> > >  <wsdl:import
> > >
location="http://192.168.98.46:8080/pfc/services/PfC?wsdl=PfC.wsdl"
> > > namespace="urn:srv"/>
> > > <wsdl:binding name="PfCServicesImplServiceSoapBinding"
type="ns1:PfC">
> > >    <soap:binding style="document"
> > >       transport="http://schemas.xmlsoap.org/soap/http"/>
> > >   <wsdl:operation name="getApplicationPushletIDs">
> > >      <soap:operation soapAction="" style="document"/>
> > >
> > >      [snip]
> > >
> > > </wsdl:binding>
> > > <wsdl:service name="PfCServicesImplService">
> > > <wsdl:port binding="ns2:PfCServicesImplServiceSoapBinding"
> > > name="PfCServicesImplPort">
> > > <soap:address
location="http://192.168.98.46:8080/pfc/services/PfC"/>
> > > </wsdl:port>
> > > </wsdl:service>
> > > </wsdl:definitions>
> > >