PortType targetnamespace

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PortType targetnamespace

Guillaume Nodet
I've spotted what I think is a bug.

When building the model from a java class using jaxws,
the PortType QName must be inferred from the @WebService
annotation on the SEI.

For example

@WebService( serviceName = "SoapService",
                       targetNamespace = "urn:greeter:service"
                       endpointInterface =
"org.apache.hello_world_soap_http.Greeter" )
public class GreeterImpl {
  ...
}

@WebService( name = "Greeter", targetNamespace = "urn:greeter:port" )
public interface Greeter {
  ...
}

must lead to a service QName of "{urn:greeter:service}SoapService",
and a PortType QName of "{urn:greeter:port}Greeter".

Due to wsdl spec, the generated wsdl must be splitted in two with
an import statement, so that the PortType can have its own
targetNamespace, different from the Service one.

The PortType QName can be easily fixed in the JaxWsServiceConfiguration with
the following code:
    @Override
    public QName getInterfaceName() {
        Class<?> epi = implInfo.getEndpointClass();
        WebService ws = null;
        if (epi != null) {
            ws = epi.getAnnotation(WebService.class);
        }
        if (ws != null && ws.name() != null && ws.name().length() > 0) {
            String name = ws.name();
            String nsuri = ws.targetNamespace();
            if (nsuri == null || nsuri.length() == 0) {
                nsuri =
ServiceUtils.makeNamespaceFromClassName(epi.getName(), "http");
            }
            return new QName(nsuri, name);
        }
        return null;
    }

However, the tooling needs some refactoring to be able to output
two different wsdls, but I think there was a plan to use to service
model ...


--
Cheers,
Guillaume Nodet
Reply | Threaded
Open this post in threaded view
|

RE: PortType targetnamespace

Jim Ma-2
Hi Nodet,

This is a bug in tooling and runtime . I will fill a jira issue for it .  

Thanks

Jim

> -----Original Message-----
> From: Guillaume Nodet [mailto:[hidden email]]
> Sent: Tuesday, November 21, 2006 7:06 AM
> To: [hidden email]
> Subject: PortType targetnamespace
>
>
> I've spotted what I think is a bug.
>
> When building the model from a java class using jaxws,
> the PortType QName must be inferred from the @WebService
> annotation on the SEI.
>
> For example
>
> @WebService( serviceName = "SoapService",
>                        targetNamespace = "urn:greeter:service"
>                        endpointInterface =
> "org.apache.hello_world_soap_http.Greeter" )
> public class GreeterImpl {
>   ...
> }
>
> @WebService( name = "Greeter", targetNamespace = "urn:greeter:port" )
> public interface Greeter {
>   ...
> }
>
> must lead to a service QName of "{urn:greeter:service}SoapService",
> and a PortType QName of "{urn:greeter:port}Greeter".
>
> Due to wsdl spec, the generated wsdl must be splitted in two with
> an import statement, so that the PortType can have its own
> targetNamespace, different from the Service one.
>
> The PortType QName can be easily fixed in the
> JaxWsServiceConfiguration with
> the following code:
>     @Override
>     public QName getInterfaceName() {
>         Class<?> epi = implInfo.getEndpointClass();
>         WebService ws = null;
>         if (epi != null) {
>             ws = epi.getAnnotation(WebService.class);
>         }
>         if (ws != null && ws.name() != null && ws.name().length() > 0) {
>             String name = ws.name();
>             String nsuri = ws.targetNamespace();
>             if (nsuri == null || nsuri.length() == 0) {
>                 nsuri =
> ServiceUtils.makeNamespaceFromClassName(epi.getName(), "http");
>             }
>             return new QName(nsuri, name);
>         }
>         return null;
>     }
>
> However, the tooling needs some refactoring to be able to output
> two different wsdls, but I think there was a plan to use to service
> model ...
>
>
> --
> Cheers,
> Guillaume Nodet