You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by iris ding <ir...@gmail.com> on 2012/11/26 03:03:03 UTC

Partial WSDL support in CXF

I have one SEI defined as below: 

@WebService(wsdlLocation="WEB-INF/wsdl/AddNumbersImplPartial1Service.wsdl")
public class AddNumbersImplPartial1 {
	
	public int addTwoNumbers(int number1, int number2) 	throws
AddNegativeNumbersException {
		if (number1 < 0 || number2 < 0) {
			throw new AddNegativeNumbersException("Negative number submitted !! ",
"Numbers: " + 
					                      number1 + ", " + number2);
		}
		return number1 + number2;
	}
}

The WEB-INF/wsdl/AddNumbersImplPartial1Service.wsdl is not complete, it only
contains to the porttype part: 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions 
targetNamespace="http://serverpartial1.partialwsdl.annotations/" 
name="AddNumbersImplPartial1Service" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:tns="http://serverpartial1.partialwsdl.annotations/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xsd:schema>
      <xsd:import namespace="http://serverpartial1.partialwsdl.annotations/"
schemaLocation="AddNumbersImplPartial1Service_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="addTwoNumbers">
    <part name="parameters" element="tns:addTwoNumbers"/>
  </message>
  <message name="addTwoNumbersResponse">
    <part name="parameters" element="tns:addTwoNumbersResponse"/>
  </message>
  <message name="AddNegativeNumbersException">
    <part name="fault" element="tns:AddNegativeNumbersException"/>
  </message>
  <portType name="AddNumbersImplPartial1">
    <operation name="addTwoNumbers">
      <input message="tns:addTwoNumbers"/>
      <output message="tns:addTwoNumbersResponse"/>
      <fault name="AddNegativeNumbersException"
message="tns:AddNegativeNumbersException"/>
    </operation>
  </portType>
  
</definitions>

Now if I put the war file into tomcat and let it use CXF, the service can
not be deployed successfully. In CXF, when it calls
WSDLServiceFactory.create, it will simply get the service name from wsdl
file and in our case, since it is empty, it will throw exception and service
deployment failed. you can reference below part:

javax.wsdl.Service wsdlService = definition.getService(serviceName);
            if (wsdlService == null) {
                throw new ServiceConstructionException(new
Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
            }

But per jaxws 2.2 spec, in chapter 5.2.5.5:

5.2.5.5 Application-specified PortType
No metadata document contains a definition for the sought-after service S,
but a metadata document, say
D, contains a definition for the WSDL portType whose qualified name, say P,
matches that specified by the
endpoint being published. In this case, a JAX-WS implementation MUST create
a new description for S,
including an appropriate WSDL binding element referencing portType P. The
metadata document D MUST
be imported/included so that the published contract uses the definition of P
provided by D. No schema generation
occurs,as P is assumed to embed or import schema definitions for all the
types/elements it requires.
Like in the previous case, the implementation MUST override any location and
schemaLocation attributes.
It is an error if more than one metadata document contains a definition for
the sought-after portType
P.

So I am wondering CXF has not followed above spec? Or should I enhance
something to let CXF support this?

Thanks!





--
View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Partial WSDL support in CXF

Posted by iris ding <ir...@gmail.com>.
I have attached a patch in cxf-4676.  Would you please help to review it? 
Also WSDLServiceFactory is also used for client side, Do we have a way to
distinguish the server or client? Currently I have not found a way to handle
this. 

Thanks a lot!

Iris Ding



--
View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5720257.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Partial WSDL support in CXF

Posted by iris ding <ir...@gmail.com>.
Hi Freeman,

Thanks a lot! I have opened a JIRA cxf-4676 to track this issue and will
provide a patch soon.

Iris Ding.



--
View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5719807.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Partial WSDL support in CXF

Posted by Freeman Fang <fr...@gmail.com>.
Sorry, I wanna say the wsdl2soap CLI tool.

Freeman
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-11-27, at 下午2:21, iris ding wrote:

> Hi Freeman,
> 
> TO use wsdl2service,
> You must specify the -n <attribute-binding-name> argument and the <wsdlurl>
> argument.  So it will have binding info from beginning.
> 
> In our case, we need to generate binding info by ourself. 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5719172.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: Partial WSDL support in CXF

Posted by iris ding <ir...@gmail.com>.
Hi Freeman,

TO use wsdl2service,
You must specify the -n <attribute-binding-name> argument and the <wsdlurl>
argument.  So it will have binding info from beginning.

In our case, we need to generate binding info by ourself. 



--
View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5719172.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Partial WSDL support in CXF

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

As it's an vague part in the spec, I'd say use the most popular soap11 binding. I believe it's also the default binding used for wsdl2service CLI tool.
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-11-27, at 下午1:32, iris ding wrote:

> Hi Freeman,
> 
> According to jaxws2.2 spec:
> 
> "No metadata document contains a definition for the sought-after service S,
> but a metadata document, say
> D, contains a definition for the WSDL portType whose qualified name, say P,
> matches that specified by the
> endpoint being published. In this case, a JAX-WS implementation MUST create
> a new description for S,
> including an appropriate WSDL binding element referencing portType P."
> 
> We need to create binding element by ourself. In such case, what binding
> type should we use?
> 
> Thanks a lot!
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5719168.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: Partial WSDL support in CXF

Posted by iris ding <ir...@gmail.com>.
Hi Freeman,

According to jaxws2.2 spec:

"No metadata document contains a definition for the sought-after service S,
but a metadata document, say
D, contains a definition for the WSDL portType whose qualified name, say P,
matches that specified by the
endpoint being published. In this case, a JAX-WS implementation MUST create
a new description for S,
including an appropriate WSDL binding element referencing portType P."

We need to create binding element by ourself. In such case, what binding
type should we use?

Thanks a lot!



--
View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5719168.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Partial WSDL support in CXF

Posted by iris ding <ir...@gmail.com>.
Hi FreeMan,

Thanks a lot!  I will open an JIRA issue and provide a patch for this.

Iris Ding



--
View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073p5719097.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Partial WSDL support in CXF

Posted by Freeman Fang <fr...@gmail.com>.
Hi Iris,

Yeah, I agree with you here.

Patch is welcomed, as always.

Btw, CXF has a wsdl2service CLI tool shipped with kit, it exactly can do the same purpose, you probably need take a look and grasp code from that tool which should be a good start for the patch.

Thanks
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-11-26, at 上午10:03, iris ding wrote:

> I have one SEI defined as below: 
> 
> @WebService(wsdlLocation="WEB-INF/wsdl/AddNumbersImplPartial1Service.wsdl")
> public class AddNumbersImplPartial1 {
> 	
> 	public int addTwoNumbers(int number1, int number2) 	throws
> AddNegativeNumbersException {
> 		if (number1 < 0 || number2 < 0) {
> 			throw new AddNegativeNumbersException("Negative number submitted !! ",
> "Numbers: " + 
> 					                      number1 + ", " + number2);
> 		}
> 		return number1 + number2;
> 	}
> }
> 
> The WEB-INF/wsdl/AddNumbersImplPartial1Service.wsdl is not complete, it only
> contains to the porttype part: 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <definitions 
> targetNamespace="http://serverpartial1.partialwsdl.annotations/" 
> name="AddNumbersImplPartial1Service" 
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> xmlns:tns="http://serverpartial1.partialwsdl.annotations/"
> xmlns="http://schemas.xmlsoap.org/wsdl/">
>  <types>
>    <xsd:schema>
>      <xsd:import namespace="http://serverpartial1.partialwsdl.annotations/"
> schemaLocation="AddNumbersImplPartial1Service_schema1.xsd"/>
>    </xsd:schema>
>  </types>
>  <message name="addTwoNumbers">
>    <part name="parameters" element="tns:addTwoNumbers"/>
>  </message>
>  <message name="addTwoNumbersResponse">
>    <part name="parameters" element="tns:addTwoNumbersResponse"/>
>  </message>
>  <message name="AddNegativeNumbersException">
>    <part name="fault" element="tns:AddNegativeNumbersException"/>
>  </message>
>  <portType name="AddNumbersImplPartial1">
>    <operation name="addTwoNumbers">
>      <input message="tns:addTwoNumbers"/>
>      <output message="tns:addTwoNumbersResponse"/>
>      <fault name="AddNegativeNumbersException"
> message="tns:AddNegativeNumbersException"/>
>    </operation>
>  </portType>
> 
> </definitions>
> 
> Now if I put the war file into tomcat and let it use CXF, the service can
> not be deployed successfully. In CXF, when it calls
> WSDLServiceFactory.create, it will simply get the service name from wsdl
> file and in our case, since it is empty, it will throw exception and service
> deployment failed. you can reference below part:
> 
> javax.wsdl.Service wsdlService = definition.getService(serviceName);
>            if (wsdlService == null) {
>                throw new ServiceConstructionException(new
> Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
>            }
> 
> But per jaxws 2.2 spec, in chapter 5.2.5.5:
> 
> 5.2.5.5 Application-specified PortType
> No metadata document contains a definition for the sought-after service S,
> but a metadata document, say
> D, contains a definition for the WSDL portType whose qualified name, say P,
> matches that specified by the
> endpoint being published. In this case, a JAX-WS implementation MUST create
> a new description for S,
> including an appropriate WSDL binding element referencing portType P. The
> metadata document D MUST
> be imported/included so that the published contract uses the definition of P
> provided by D. No schema generation
> occurs,as P is assumed to embed or import schema definitions for all the
> types/elements it requires.
> Like in the previous case, the implementation MUST override any location and
> schemaLocation attributes.
> It is an error if more than one metadata document contains a definition for
> the sought-after portType
> P.
> 
> So I am wondering CXF has not followed above spec? Or should I enhance
> something to let CXF support this?
> 
> Thanks!
> 
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Partial-WSDL-support-in-CXF-tp5719073.html
> Sent from the cxf-user mailing list archive at Nabble.com.