You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "krn1231@gmail.com" <kr...@gmail.com> on 2012/01/12 16:11:04 UTC

How can i make a Field Mantadatory in WSDL through Java Code

I am using Apache CXF for developing Web services . This is some part of WSDL
generated by the Apache CXF Soap Engine

*<xs:complexContent>
<xs:extension base="tns:serviceRequest">
<xs:sequence>
<xs:element minOccurs="0" name="xmlMessage" type="xs:string"/>
<xs:element minOccurs="0" name="orderInputForm" type="tns:orderForm"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>*
Please let me know how can i make sure that a particular field is
mantadatory ??

When i tried using // @XmlElement(required = true)  private String           
xmlMessage ;

As the WSDL is generated by Apache CXF Engine , i dont have any control on
WSDL file . So i need to make changes inside the java code itself , so that
on to the WSDL it displays that a particular field is mantadatory


 By this the  Application did not started  , It had Errors on Server console
SEVERE: Error listenerStart Jan 12, 2012 8:34:03 PM
org.apache.catalina.core.StandardContext start SEVERE: Context [/tata-ws]
startup failed due to previous errors


Please tell me how can i make a Field Mantadatory ??

Thanks 

--
View this message in context: http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-through-Java-Code-tp5140164p5140164.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: How can i make a Field Mantadatory in WSDL through Java Code

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday, January 18, 2012 5:22:36 PM canterburry wrote:
> OK...just discovered that the minOccurs=0 vs 1 does get generated correctly,
> but only for classes in the same maven project as my java2ws plugin.
> Annotated classes that are dependencies do not seem to be correctly
> detected. Is there a limitation to multi-project maven builds when using
> the java2ws plugin?

There definitely shouldn't be.   Maven should be handing the dependency jars 
to the plugin and as long as the required dependencies (like the jaxb-api jar) 
are found, it should work fine.

Any chance of creating a testcase?

Dan



> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-
> through-Java-Code-tp5140164p5156522.html Sent from the cxf-user mailing list
> archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: How can i make a Field Mantadatory in WSDL through Java Code

Posted by Glen Mazza <gm...@talend.com>.
Unless I'm misunderstanding your question, the java2ws plugin, like all 
plugins, will activate only for the specific project in which it is 
defined, not its dependencies.  Even if you define all its parameters 
within a <plugindependency/> in a parent pom, it still needs to be 
explicitly declared within each dependency for which you want it activated.

Glen

On 01/18/2012 08:22 PM, canterburry wrote:
> OK...just discovered that the minOccurs=0 vs 1 does get generated correctly,
> but only for classes in the same maven project as my java2ws plugin.
> Annotated classes that are dependencies do not seem to be correctly
> detected. Is there a limitation to multi-project maven builds when using the
> java2ws plugin?
>
> --
> View this message in context:http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-through-Java-Code-tp5140164p5156522.html
> Sent from the cxf-user mailing list archive at Nabble.com.



Re: Https policy with spring

Posted by Glen Mazza <gm...@talend.com>.
But AFAIK for Tomcat the SSL is enforced at the servlet-level 
(http://www.jroller.com/gmazza/entry/ssl_for_web_services#SSL4), or more 
accurately, via a url-pattern, which in turn gets mapped to a servlet or 
multiple servlets.  So even if you have multiple paths/contexts being 
routed to a single servlet, so long as you know the servlet it's being 
routed to you'll know whether SSL is being enforced for all of those 
paths/contexts.

Glen

On 01/20/2012 12:19 PM, Sven Zethelius wrote:
> I don't think its something you can necessarily determine at the Servlet / ServletContext.  Since multiple pathes / Context can be routed to a single servlet instance, it makes sense that you ask the request (http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#isSecure())
>
> ________________________________________
> From: Glen Mazza [gmazza@talend.com]
> Sent: Friday, January 20, 2012 9:15 AM
> To: users@cxf.apache.org
> Subject: Re: Https policy with spring
>
> I don't know how accurate that is, that's why I was recommending asking
> the Tomcat User's list.  For what XiLai is asking for, 98% accurate
> might not be good enough.
>
> Glen
>
> On 01/20/2012 12:02 PM, Sergey Beryozkin wrote:
>> On 20/01/12 16:35, Glen Mazza wrote:
>>> I'm not sure here--if I understand you correctly, a more generic version
>>> of the question you're asking is "How can a servlet determine whether it
>>> is being run over https:// or not?" This might be a question better
>>> asked on the Tomcat user's list. If it is not possible for a servlet to
>>> be able to determine that in a formal, rigorous manner (i.e., perhaps
>>> servlets are sandboxed by the servlet container so they can't know
>>> whether they're running over https), then at the web service provider
>>> level I don't see how it can make that determination either.
>>>
>> Would checking the request URI and seeing if it starts with 'https' do ?
>>
>> Sergey
>>
>>> Glen
>>>
>>> On 01/19/2012 08:35 PM, XiLai Dai wrote:
>>>> Thanks Colm and Glen!
>>>>
>>>> but maybe my question was not clear, what we want to do was checking
>>>> if the Endpoint secured by policy after adding https policy to
>>>> the<jaxws:endpoint>.
>>>>
>>>> the java codes used for checking looks like:
>>>>
>>>> private boolean isSecuredByPolicy(Server server) {
>>>> boolean isSecured = false;
>>>>
>>>> EndpointInfo ei = server.getEndpoint().getEndpointInfo();
>>>>
>>>> PolicyEngine pe = bus.getExtension(PolicyEngine.class);
>>>> if (null == pe) {
>>>> LOG.finest("No Policy engine found");
>>>> return isSecured;
>>>> }
>>>>
>>>> Destination destination = server.getDestination();
>>>> EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
>>>> Collection<Assertion>  assertions = ep.getChosenAlternative();
>>>> for (Assertion a : assertions) {
>>>> if (a instanceof TransportBinding) {
>>>> TransportBinding tb = (TransportBinding)a;
>>>> TransportToken tt = tb.getTransportToken();
>>>> Token t = tt.getTransportToken();
>>>> if (t instanceof HttpsToken) {
>>>> isSecured = true;
>>>> break;
>>>> }
>>>> }
>>>> }
>>>>
>>>> Policy policy = ep.getPolicy();
>>>> List<PolicyComponent>  pcList = policy.getPolicyComponents();
>>>> for (PolicyComponent a : pcList) {
>>>> if (a instanceof TransportBinding) {
>>>> TransportBinding tb = (TransportBinding)a;
>>>> TransportToken tt = tb.getTransportToken();
>>>> Token t = tt.getTransportToken();
>>>> if (t instanceof HttpsToken) {
>>>> isSecured = true;
>>>> break;
>>>> }
>>>> }
>>>> }
>>>>
>>>> return isSecured;
>>>> }
>>>>
>>>> but the return value always false :(
>>>>
>>>> Thanks!
>>>> Xilai
>>>> ________________________________________
>>>>
>>>> Information on setting up Tomcat for SSL is here:
>>>> http://www.jroller.com/gmazza/entry/ssl_for_web_services
>>>>
>>>> HTH,
>>>> Glen
>>>>
>>>> On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
>>>>> Hi,
>>>>>
>>>>>> It can be published with no error, but from the debugging there is
>>>>>> no any Assertion found, so the Https transport didn't take effect.
>>>>> The policy looks ok - how are you setting up the TLS endpoint though?
>>>>> Adding a TransportBinding policy does not set up TLS, it's up to the
>>>>> container to do that, or else you can add a "httpj:engine-factory"
>>>>> configuration if using Jetty.
>>>>>
>>>>> Colm.
>>>>>
>>>>> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com>  wrote:
>>>>>> Hello,
>>>>>>
>>>>>> We have a jaxws:endpoint defined like this:
>>>>>> <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>>>>> id="greeter_Https"
>>>>>> implementor="demo.service.Greeter_HttpsImpl"
>>>>>> serviceName="tns:Greeter_HttpsService"
>>>>>> address="/Greeter_HttpsService">
>>>>>> <jaxws:features>
>>>>>> <p:policies>
>>>>>> <wsp:Policy>
>>>>>> <wsp:ExactlyOne>
>>>>>> <wsp:All>
>>>>>> <sp:TransportBinding
>>>>>> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>>>>> <wsp:Policy>
>>>>>> <sp:TransportToken>
>>>>>> <wsp:Policy>
>>>>>> <sp:HttpsToken RequireClientCertificate="false"/>
>>>>>> </wsp:Policy>
>>>>>> </sp:TransportToken>
>>>>>> </wsp:Policy>
>>>>>> </sp:TransportBinding>
>>>>>> </wsp:All>
>>>>>> </wsp:ExactlyOne>
>>>>>> </wsp:Policy>
>>>>>> </p:policies>
>>>>>> </jaxws:features>
>>>>>> </jaxws:endpoint>
>>>>>>
>>>>>> It can be published with no error, but from the debugging there is
>>>>>> no any Assertion found, so the Https transport didn't take effect.
>>>>>> Can someone take a look what's wrong with the definition of policy?
>>>>>> Thanks in advance.
>>>>>>
>>>>>> Regards.
>>>>>> Xilai
>>>> --
>>>> Glen Mazza
>>>> Talend Community Coders - coders.talend.com
>>>> blog: www.jroller.com/gmazza
>>>>
>>>
>>
>
> --
> Glen Mazza
> Talend Community Coders - coders.talend.com
> blog: www.jroller.com/gmazza


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza


RE: Https policy with spring

Posted by Sven Zethelius <sv...@expedia.com>.
I don't think its something you can necessarily determine at the Servlet / ServletContext.  Since multiple pathes / Context can be routed to a single servlet instance, it makes sense that you ask the request (http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#isSecure()) 

________________________________________
From: Glen Mazza [gmazza@talend.com]
Sent: Friday, January 20, 2012 9:15 AM
To: users@cxf.apache.org
Subject: Re: Https policy with spring

I don't know how accurate that is, that's why I was recommending asking
the Tomcat User's list.  For what XiLai is asking for, 98% accurate
might not be good enough.

Glen

On 01/20/2012 12:02 PM, Sergey Beryozkin wrote:
> On 20/01/12 16:35, Glen Mazza wrote:
>> I'm not sure here--if I understand you correctly, a more generic version
>> of the question you're asking is "How can a servlet determine whether it
>> is being run over https:// or not?" This might be a question better
>> asked on the Tomcat user's list. If it is not possible for a servlet to
>> be able to determine that in a formal, rigorous manner (i.e., perhaps
>> servlets are sandboxed by the servlet container so they can't know
>> whether they're running over https), then at the web service provider
>> level I don't see how it can make that determination either.
>>
>
> Would checking the request URI and seeing if it starts with 'https' do ?
>
> Sergey
>
>> Glen
>>
>> On 01/19/2012 08:35 PM, XiLai Dai wrote:
>>> Thanks Colm and Glen!
>>>
>>> but maybe my question was not clear, what we want to do was checking
>>> if the Endpoint secured by policy after adding https policy to
>>> the<jaxws:endpoint>.
>>>
>>> the java codes used for checking looks like:
>>>
>>> private boolean isSecuredByPolicy(Server server) {
>>> boolean isSecured = false;
>>>
>>> EndpointInfo ei = server.getEndpoint().getEndpointInfo();
>>>
>>> PolicyEngine pe = bus.getExtension(PolicyEngine.class);
>>> if (null == pe) {
>>> LOG.finest("No Policy engine found");
>>> return isSecured;
>>> }
>>>
>>> Destination destination = server.getDestination();
>>> EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
>>> Collection<Assertion> assertions = ep.getChosenAlternative();
>>> for (Assertion a : assertions) {
>>> if (a instanceof TransportBinding) {
>>> TransportBinding tb = (TransportBinding)a;
>>> TransportToken tt = tb.getTransportToken();
>>> Token t = tt.getTransportToken();
>>> if (t instanceof HttpsToken) {
>>> isSecured = true;
>>> break;
>>> }
>>> }
>>> }
>>>
>>> Policy policy = ep.getPolicy();
>>> List<PolicyComponent> pcList = policy.getPolicyComponents();
>>> for (PolicyComponent a : pcList) {
>>> if (a instanceof TransportBinding) {
>>> TransportBinding tb = (TransportBinding)a;
>>> TransportToken tt = tb.getTransportToken();
>>> Token t = tt.getTransportToken();
>>> if (t instanceof HttpsToken) {
>>> isSecured = true;
>>> break;
>>> }
>>> }
>>> }
>>>
>>> return isSecured;
>>> }
>>>
>>> but the return value always false :(
>>>
>>> Thanks!
>>> Xilai
>>> ________________________________________
>>>
>>> Information on setting up Tomcat for SSL is here:
>>> http://www.jroller.com/gmazza/entry/ssl_for_web_services
>>>
>>> HTH,
>>> Glen
>>>
>>> On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
>>>> Hi,
>>>>
>>>>> It can be published with no error, but from the debugging there is
>>>>> no any Assertion found, so the Https transport didn't take effect.
>>>> The policy looks ok - how are you setting up the TLS endpoint though?
>>>> Adding a TransportBinding policy does not set up TLS, it's up to the
>>>> container to do that, or else you can add a "httpj:engine-factory"
>>>> configuration if using Jetty.
>>>>
>>>> Colm.
>>>>
>>>> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com> wrote:
>>>>> Hello,
>>>>>
>>>>> We have a jaxws:endpoint defined like this:
>>>>> <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>>>> id="greeter_Https"
>>>>> implementor="demo.service.Greeter_HttpsImpl"
>>>>> serviceName="tns:Greeter_HttpsService"
>>>>> address="/Greeter_HttpsService">
>>>>> <jaxws:features>
>>>>> <p:policies>
>>>>> <wsp:Policy>
>>>>> <wsp:ExactlyOne>
>>>>> <wsp:All>
>>>>> <sp:TransportBinding
>>>>> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>>>> <wsp:Policy>
>>>>> <sp:TransportToken>
>>>>> <wsp:Policy>
>>>>> <sp:HttpsToken RequireClientCertificate="false"/>
>>>>> </wsp:Policy>
>>>>> </sp:TransportToken>
>>>>> </wsp:Policy>
>>>>> </sp:TransportBinding>
>>>>> </wsp:All>
>>>>> </wsp:ExactlyOne>
>>>>> </wsp:Policy>
>>>>> </p:policies>
>>>>> </jaxws:features>
>>>>> </jaxws:endpoint>
>>>>>
>>>>> It can be published with no error, but from the debugging there is
>>>>> no any Assertion found, so the Https transport didn't take effect.
>>>>> Can someone take a look what's wrong with the definition of policy?
>>>>> Thanks in advance.
>>>>>
>>>>> Regards.
>>>>> Xilai
>>>>
>>>
>>> --
>>> Glen Mazza
>>> Talend Community Coders - coders.talend.com
>>> blog: www.jroller.com/gmazza
>>>
>>
>>
>
>


--
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza

Re: Https policy with spring

Posted by Glen Mazza <gm...@talend.com>.
I don't know how accurate that is, that's why I was recommending asking 
the Tomcat User's list.  For what XiLai is asking for, 98% accurate 
might not be good enough.

Glen

On 01/20/2012 12:02 PM, Sergey Beryozkin wrote:
> On 20/01/12 16:35, Glen Mazza wrote:
>> I'm not sure here--if I understand you correctly, a more generic version
>> of the question you're asking is "How can a servlet determine whether it
>> is being run over https:// or not?" This might be a question better
>> asked on the Tomcat user's list. If it is not possible for a servlet to
>> be able to determine that in a formal, rigorous manner (i.e., perhaps
>> servlets are sandboxed by the servlet container so they can't know
>> whether they're running over https), then at the web service provider
>> level I don't see how it can make that determination either.
>>
>
> Would checking the request URI and seeing if it starts with 'https' do ?
>
> Sergey
>
>> Glen
>>
>> On 01/19/2012 08:35 PM, XiLai Dai wrote:
>>> Thanks Colm and Glen!
>>>
>>> but maybe my question was not clear, what we want to do was checking
>>> if the Endpoint secured by policy after adding https policy to
>>> the<jaxws:endpoint>.
>>>
>>> the java codes used for checking looks like:
>>>
>>> private boolean isSecuredByPolicy(Server server) {
>>> boolean isSecured = false;
>>>
>>> EndpointInfo ei = server.getEndpoint().getEndpointInfo();
>>>
>>> PolicyEngine pe = bus.getExtension(PolicyEngine.class);
>>> if (null == pe) {
>>> LOG.finest("No Policy engine found");
>>> return isSecured;
>>> }
>>>
>>> Destination destination = server.getDestination();
>>> EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
>>> Collection<Assertion> assertions = ep.getChosenAlternative();
>>> for (Assertion a : assertions) {
>>> if (a instanceof TransportBinding) {
>>> TransportBinding tb = (TransportBinding)a;
>>> TransportToken tt = tb.getTransportToken();
>>> Token t = tt.getTransportToken();
>>> if (t instanceof HttpsToken) {
>>> isSecured = true;
>>> break;
>>> }
>>> }
>>> }
>>>
>>> Policy policy = ep.getPolicy();
>>> List<PolicyComponent> pcList = policy.getPolicyComponents();
>>> for (PolicyComponent a : pcList) {
>>> if (a instanceof TransportBinding) {
>>> TransportBinding tb = (TransportBinding)a;
>>> TransportToken tt = tb.getTransportToken();
>>> Token t = tt.getTransportToken();
>>> if (t instanceof HttpsToken) {
>>> isSecured = true;
>>> break;
>>> }
>>> }
>>> }
>>>
>>> return isSecured;
>>> }
>>>
>>> but the return value always false :(
>>>
>>> Thanks!
>>> Xilai
>>> ________________________________________
>>>
>>> Information on setting up Tomcat for SSL is here:
>>> http://www.jroller.com/gmazza/entry/ssl_for_web_services
>>>
>>> HTH,
>>> Glen
>>>
>>> On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
>>>> Hi,
>>>>
>>>>> It can be published with no error, but from the debugging there is
>>>>> no any Assertion found, so the Https transport didn't take effect.
>>>> The policy looks ok - how are you setting up the TLS endpoint though?
>>>> Adding a TransportBinding policy does not set up TLS, it's up to the
>>>> container to do that, or else you can add a "httpj:engine-factory"
>>>> configuration if using Jetty.
>>>>
>>>> Colm.
>>>>
>>>> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com> wrote:
>>>>> Hello,
>>>>>
>>>>> We have a jaxws:endpoint defined like this:
>>>>> <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>>>> id="greeter_Https"
>>>>> implementor="demo.service.Greeter_HttpsImpl"
>>>>> serviceName="tns:Greeter_HttpsService"
>>>>> address="/Greeter_HttpsService">
>>>>> <jaxws:features>
>>>>> <p:policies>
>>>>> <wsp:Policy>
>>>>> <wsp:ExactlyOne>
>>>>> <wsp:All>
>>>>> <sp:TransportBinding
>>>>> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>>>> <wsp:Policy>
>>>>> <sp:TransportToken>
>>>>> <wsp:Policy>
>>>>> <sp:HttpsToken RequireClientCertificate="false"/>
>>>>> </wsp:Policy>
>>>>> </sp:TransportToken>
>>>>> </wsp:Policy>
>>>>> </sp:TransportBinding>
>>>>> </wsp:All>
>>>>> </wsp:ExactlyOne>
>>>>> </wsp:Policy>
>>>>> </p:policies>
>>>>> </jaxws:features>
>>>>> </jaxws:endpoint>
>>>>>
>>>>> It can be published with no error, but from the debugging there is
>>>>> no any Assertion found, so the Https transport didn't take effect.
>>>>> Can someone take a look what's wrong with the definition of policy?
>>>>> Thanks in advance.
>>>>>
>>>>> Regards.
>>>>> Xilai
>>>>
>>>
>>> -- 
>>> Glen Mazza
>>> Talend Community Coders - coders.talend.com
>>> blog: www.jroller.com/gmazza
>>>
>>
>>
>
>


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza


Re: Https policy with spring

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 20/01/12 16:35, Glen Mazza wrote:
> I'm not sure here--if I understand you correctly, a more generic version
> of the question you're asking is "How can a servlet determine whether it
> is being run over https:// or not?" This might be a question better
> asked on the Tomcat user's list. If it is not possible for a servlet to
> be able to determine that in a formal, rigorous manner (i.e., perhaps
> servlets are sandboxed by the servlet container so they can't know
> whether they're running over https), then at the web service provider
> level I don't see how it can make that determination either.
>

Would checking the request URI and seeing if it starts with 'https' do ?

Sergey

> Glen
>
> On 01/19/2012 08:35 PM, XiLai Dai wrote:
>> Thanks Colm and Glen!
>>
>> but maybe my question was not clear, what we want to do was checking
>> if the Endpoint secured by policy after adding https policy to
>> the<jaxws:endpoint>.
>>
>> the java codes used for checking looks like:
>>
>> private boolean isSecuredByPolicy(Server server) {
>> boolean isSecured = false;
>>
>> EndpointInfo ei = server.getEndpoint().getEndpointInfo();
>>
>> PolicyEngine pe = bus.getExtension(PolicyEngine.class);
>> if (null == pe) {
>> LOG.finest("No Policy engine found");
>> return isSecured;
>> }
>>
>> Destination destination = server.getDestination();
>> EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
>> Collection<Assertion> assertions = ep.getChosenAlternative();
>> for (Assertion a : assertions) {
>> if (a instanceof TransportBinding) {
>> TransportBinding tb = (TransportBinding)a;
>> TransportToken tt = tb.getTransportToken();
>> Token t = tt.getTransportToken();
>> if (t instanceof HttpsToken) {
>> isSecured = true;
>> break;
>> }
>> }
>> }
>>
>> Policy policy = ep.getPolicy();
>> List<PolicyComponent> pcList = policy.getPolicyComponents();
>> for (PolicyComponent a : pcList) {
>> if (a instanceof TransportBinding) {
>> TransportBinding tb = (TransportBinding)a;
>> TransportToken tt = tb.getTransportToken();
>> Token t = tt.getTransportToken();
>> if (t instanceof HttpsToken) {
>> isSecured = true;
>> break;
>> }
>> }
>> }
>>
>> return isSecured;
>> }
>>
>> but the return value always false :(
>>
>> Thanks!
>> Xilai
>> ________________________________________
>>
>> Information on setting up Tomcat for SSL is here:
>> http://www.jroller.com/gmazza/entry/ssl_for_web_services
>>
>> HTH,
>> Glen
>>
>> On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
>>> Hi,
>>>
>>>> It can be published with no error, but from the debugging there is
>>>> no any Assertion found, so the Https transport didn't take effect.
>>> The policy looks ok - how are you setting up the TLS endpoint though?
>>> Adding a TransportBinding policy does not set up TLS, it's up to the
>>> container to do that, or else you can add a "httpj:engine-factory"
>>> configuration if using Jetty.
>>>
>>> Colm.
>>>
>>> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com> wrote:
>>>> Hello,
>>>>
>>>> We have a jaxws:endpoint defined like this:
>>>> <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>>> id="greeter_Https"
>>>> implementor="demo.service.Greeter_HttpsImpl"
>>>> serviceName="tns:Greeter_HttpsService"
>>>> address="/Greeter_HttpsService">
>>>> <jaxws:features>
>>>> <p:policies>
>>>> <wsp:Policy>
>>>> <wsp:ExactlyOne>
>>>> <wsp:All>
>>>> <sp:TransportBinding
>>>> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>>> <wsp:Policy>
>>>> <sp:TransportToken>
>>>> <wsp:Policy>
>>>> <sp:HttpsToken RequireClientCertificate="false"/>
>>>> </wsp:Policy>
>>>> </sp:TransportToken>
>>>> </wsp:Policy>
>>>> </sp:TransportBinding>
>>>> </wsp:All>
>>>> </wsp:ExactlyOne>
>>>> </wsp:Policy>
>>>> </p:policies>
>>>> </jaxws:features>
>>>> </jaxws:endpoint>
>>>>
>>>> It can be published with no error, but from the debugging there is
>>>> no any Assertion found, so the Https transport didn't take effect.
>>>> Can someone take a look what's wrong with the definition of policy?
>>>> Thanks in advance.
>>>>
>>>> Regards.
>>>> Xilai
>>>
>>
>> --
>> Glen Mazza
>> Talend Community Coders - coders.talend.com
>> blog: www.jroller.com/gmazza
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Https policy with spring

Posted by Glen Mazza <gm...@talend.com>.
I'm not sure here--if I understand you correctly, a more generic version 
of the question you're asking is "How can a servlet determine whether it 
is being run over https:// or not?"  This might be a question better 
asked on the Tomcat user's list.  If it is not possible for a servlet to 
be able to determine that in a formal, rigorous manner (i.e., perhaps 
servlets are sandboxed by the servlet container so they can't know 
whether they're running over https), then at the web service provider 
level I don't see how it can make that determination either.

Glen

On 01/19/2012 08:35 PM, XiLai Dai wrote:
> Thanks Colm and Glen!
>
> but maybe my question was not clear, what we want to do was checking if the Endpoint secured by policy after adding https policy to the<jaxws:endpoint>.
>
> the java codes used for checking looks like:
>
>      private boolean isSecuredByPolicy(Server server) {
>          boolean isSecured = false;
>
>          EndpointInfo ei = server.getEndpoint().getEndpointInfo();
>
>          PolicyEngine pe = bus.getExtension(PolicyEngine.class);
>          if (null == pe) {
>              LOG.finest("No Policy engine found");
>              return isSecured;
>          }
>
>          Destination destination = server.getDestination();
>          EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
>          Collection<Assertion>  assertions = ep.getChosenAlternative();
>          for (Assertion a : assertions) {
>              if (a instanceof TransportBinding) {
>                  TransportBinding tb = (TransportBinding)a;
>                  TransportToken tt = tb.getTransportToken();
>                  Token t = tt.getTransportToken();
>                  if (t instanceof HttpsToken) {
>                      isSecured = true;
>                      break;
>                  }
>              }
>          }
>
>          Policy policy = ep.getPolicy();
>          List<PolicyComponent>  pcList = policy.getPolicyComponents();
>          for (PolicyComponent a : pcList) {
>              if (a instanceof TransportBinding) {
>                  TransportBinding tb = (TransportBinding)a;
>                  TransportToken tt = tb.getTransportToken();
>                  Token t = tt.getTransportToken();
>                  if (t instanceof HttpsToken) {
>                      isSecured = true;
>                      break;
>                  }
>              }
>          }
>
>          return isSecured;
>      }
>
> but the return value always false :(
>
> Thanks!
> Xilai
> ________________________________________
>
> Information on setting up Tomcat for SSL is here:
> http://www.jroller.com/gmazza/entry/ssl_for_web_services
>
> HTH,
> Glen
>
> On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
>> Hi,
>>
>>> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
>> The policy looks ok - how are you setting up the TLS endpoint though?
>> Adding a TransportBinding policy does not set up TLS, it's up to the
>> container to do that, or else you can add a "httpj:engine-factory"
>> configuration if using Jetty.
>>
>> Colm.
>>
>> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com>   wrote:
>>> Hello,
>>>
>>> We have a jaxws:endpoint defined like this:
>>>          <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>>                          id="greeter_Https"
>>>                          implementor="demo.service.Greeter_HttpsImpl"
>>>                          serviceName="tns:Greeter_HttpsService"
>>>                          address="/Greeter_HttpsService">
>>>        <jaxws:features>
>>>                          <p:policies>
>>>                                  <wsp:Policy>
>>>                                          <wsp:ExactlyOne>
>>>                                                  <wsp:All>
>>>                                                    <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>>                                                          <wsp:Policy>
>>>                                                            <sp:TransportToken>
>>>                                                              <wsp:Policy>
>>>                                                                <sp:HttpsToken RequireClientCertificate="false"/>
>>>                                                              </wsp:Policy>
>>>                                                            </sp:TransportToken>
>>>                                                          </wsp:Policy>
>>>                                                    </sp:TransportBinding>
>>>                                                  </wsp:All>
>>>                                          </wsp:ExactlyOne>
>>>                                  </wsp:Policy>
>>>                          </p:policies>
>>>            </jaxws:features>
>>>          </jaxws:endpoint>
>>>
>>> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
>>> Can someone take a look what's wrong with the definition of policy? Thanks in advance.
>>>
>>> Regards.
>>> Xilai
>>
>
> --
> Glen Mazza
> Talend Community Coders - coders.talend.com
> blog: www.jroller.com/gmazza
>


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza


re: Https policy with spring

Posted by XiLai Dai <xl...@talend.com>.
Thanks Colm and Glen!

but maybe my question was not clear, what we want to do was checking if the Endpoint secured by policy after adding https policy to the <jaxws:endpoint>.

the java codes used for checking looks like:

    private boolean isSecuredByPolicy(Server server) {
        boolean isSecured = false;

        EndpointInfo ei = server.getEndpoint().getEndpointInfo();

        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
        if (null == pe) {
            LOG.finest("No Policy engine found");
            return isSecured;
        }

        Destination destination = server.getDestination();
        EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
        Collection<Assertion> assertions = ep.getChosenAlternative();
        for (Assertion a : assertions) {
            if (a instanceof TransportBinding) {
                TransportBinding tb = (TransportBinding)a;
                TransportToken tt = tb.getTransportToken();
                Token t = tt.getTransportToken();
                if (t instanceof HttpsToken) {
                    isSecured = true;
                    break;
                }
            }
        }

        Policy policy = ep.getPolicy();
        List<PolicyComponent> pcList = policy.getPolicyComponents();
        for (PolicyComponent a : pcList) {
            if (a instanceof TransportBinding) {
                TransportBinding tb = (TransportBinding)a;
                TransportToken tt = tb.getTransportToken();
                Token t = tt.getTransportToken();
                if (t instanceof HttpsToken) {
                    isSecured = true;
                    break;
                }
            }
        }

        return isSecured;
    }

but the return value always false :(

Thanks!
Xilai
________________________________________

Information on setting up Tomcat for SSL is here:
http://www.jroller.com/gmazza/entry/ssl_for_web_services

HTH,
Glen

On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
> Hi,
>
>> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
> The policy looks ok - how are you setting up the TLS endpoint though?
> Adding a TransportBinding policy does not set up TLS, it's up to the
> container to do that, or else you can add a "httpj:engine-factory"
> configuration if using Jetty.
>
> Colm.
>
> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com>  wrote:
>> Hello,
>>
>> We have a jaxws:endpoint defined like this:
>>         <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>                         id="greeter_Https"
>>                         implementor="demo.service.Greeter_HttpsImpl"
>>                         serviceName="tns:Greeter_HttpsService"
>>                         address="/Greeter_HttpsService">
>>       <jaxws:features>
>>                         <p:policies>
>>                                 <wsp:Policy>
>>                                         <wsp:ExactlyOne>
>>                                                 <wsp:All>
>>                                                   <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>                                                         <wsp:Policy>
>>                                                           <sp:TransportToken>
>>                                                             <wsp:Policy>
>>                                                               <sp:HttpsToken RequireClientCertificate="false"/>
>>                                                             </wsp:Policy>
>>                                                           </sp:TransportToken>
>>                                                         </wsp:Policy>
>>                                                   </sp:TransportBinding>
>>                                                 </wsp:All>
>>                                         </wsp:ExactlyOne>
>>                                 </wsp:Policy>
>>                         </p:policies>
>>           </jaxws:features>
>>         </jaxws:endpoint>
>>
>> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
>> Can someone take a look what's wrong with the definition of policy? Thanks in advance.
>>
>> Regards.
>> Xilai
>
>


--
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza


Re: Https policy with spring

Posted by Glen Mazza <gm...@talend.com>.
Information on setting up Tomcat for SSL is here:
http://www.jroller.com/gmazza/entry/ssl_for_web_services

HTH,
Glen

On 01/19/2012 05:42 AM, Colm O hEigeartaigh wrote:
> Hi,
>
>> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
> The policy looks ok - how are you setting up the TLS endpoint though?
> Adding a TransportBinding policy does not set up TLS, it's up to the
> container to do that, or else you can add a "httpj:engine-factory"
> configuration if using Jetty.
>
> Colm.
>
> On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai<xl...@talend.com>  wrote:
>> Hello,
>>
>> We have a jaxws:endpoint defined like this:
>>         <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>>                         id="greeter_Https"
>>                         implementor="demo.service.Greeter_HttpsImpl"
>>                         serviceName="tns:Greeter_HttpsService"
>>                         address="/Greeter_HttpsService">
>>       <jaxws:features>
>>                         <p:policies>
>>                                 <wsp:Policy>
>>                                         <wsp:ExactlyOne>
>>                                                 <wsp:All>
>>                                                   <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>                                                         <wsp:Policy>
>>                                                           <sp:TransportToken>
>>                                                             <wsp:Policy>
>>                                                               <sp:HttpsToken RequireClientCertificate="false"/>
>>                                                             </wsp:Policy>
>>                                                           </sp:TransportToken>
>>                                                         </wsp:Policy>
>>                                                   </sp:TransportBinding>
>>                                                 </wsp:All>
>>                                         </wsp:ExactlyOne>
>>                                 </wsp:Policy>
>>                         </p:policies>
>>           </jaxws:features>
>>         </jaxws:endpoint>
>>
>> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
>> Can someone take a look what's wrong with the definition of policy? Thanks in advance.
>>
>> Regards.
>> Xilai
>
>


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza


Re: Https policy with spring

Posted by Colm O hEigeartaigh <co...@apache.org>.
Hi,

> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.

The policy looks ok - how are you setting up the TLS endpoint though?
Adding a TransportBinding policy does not set up TLS, it's up to the
container to do that, or else you can add a "httpj:engine-factory"
configuration if using Jetty.

Colm.

On Thu, Jan 19, 2012 at 4:00 AM, XiLai Dai <xl...@talend.com> wrote:
> Hello,
>
> We have a jaxws:endpoint defined like this:
>        <jaxws:endpoint xmlns:tns="http://my.org/examples/"
>                        id="greeter_Https"
>                        implementor="demo.service.Greeter_HttpsImpl"
>                        serviceName="tns:Greeter_HttpsService"
>                        address="/Greeter_HttpsService">
>      <jaxws:features>
>                        <p:policies>
>                                <wsp:Policy>
>                                        <wsp:ExactlyOne>
>                                                <wsp:All>
>                                                  <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>                                                        <wsp:Policy>
>                                                          <sp:TransportToken>
>                                                            <wsp:Policy>
>                                                              <sp:HttpsToken RequireClientCertificate="false"/>
>                                                            </wsp:Policy>
>                                                          </sp:TransportToken>
>                                                        </wsp:Policy>
>                                                  </sp:TransportBinding>
>                                                </wsp:All>
>                                        </wsp:ExactlyOne>
>                                </wsp:Policy>
>                        </p:policies>
>          </jaxws:features>
>        </jaxws:endpoint>
>
> It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
> Can someone take a look what's wrong with the definition of policy? Thanks in advance.
>
> Regards.
> Xilai



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Https policy with spring

Posted by XiLai Dai <xl...@talend.com>.
Hello,

We have a jaxws:endpoint defined like this:
	<jaxws:endpoint xmlns:tns="http://my.org/examples/"
			id="greeter_Https"
			implementor="demo.service.Greeter_HttpsImpl"
			serviceName="tns:Greeter_HttpsService"
			address="/Greeter_HttpsService">
      <jaxws:features>
			<p:policies>
				<wsp:Policy>
					<wsp:ExactlyOne>
						<wsp:All>
						  <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
							<wsp:Policy>
							  <sp:TransportToken>
							    <wsp:Policy>
							      <sp:HttpsToken RequireClientCertificate="false"/>
							    </wsp:Policy>
							  </sp:TransportToken>
							</wsp:Policy>
						  </sp:TransportBinding>
						</wsp:All>
					</wsp:ExactlyOne>
				</wsp:Policy>
			</p:policies>
	  </jaxws:features>
	</jaxws:endpoint>

It can be published with no error, but from the debugging there is no any Assertion found, so the Https transport didn't take effect.
Can someone take a look what's wrong with the definition of policy? Thanks in advance.

Regards.
Xilai

Re: How can i make a Field Mantadatory in WSDL through Java Code

Posted by canterburry <ca...@gmail.com>.
OK...just discovered that the minOccurs=0 vs 1 does get generated correctly,
but only for classes in the same maven project as my java2ws plugin.
Annotated classes that are dependencies do not seem to be correctly
detected. Is there a limitation to multi-project maven builds when using the
java2ws plugin?

--
View this message in context: http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-through-Java-Code-tp5140164p5156522.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: How can i make a Field Mantadatory in WSDL through Java Code

Posted by canterburry <ca...@gmail.com>.
I am having a similar problem with minOccurs=0 being generated in my WSDL no
matter what I put in the @XmlElement annotation.

I am using java2ws maven plugin v 2.5.1 to generate the WSDL and regardless
of if I put @XmlElement(required=true) or @XmlElement(required=true,
nillable=false) or just @XmlElement(nillable=false) I still get minOccurs=0.
I am placing this annotation at the field level. 

--
View this message in context: http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-through-Java-Code-tp5140164p5156496.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: How can i make a Field Mantadatory in WSDL through Java Code

Posted by Daniel Kulp <dk...@apache.org>.
The  @XmlElement(required = true)  on the field should definitely do it.   Are 
you sure the new version wasn't being picked up?  Is there a full stack trace 
for that?


Dan


On Thursday, January 12, 2012 7:11:04 AM krn1231@gmail.com wrote:
> I am using Apache CXF for developing Web services . This is some part of
> WSDL generated by the Apache CXF Soap Engine
> 
> *<xs:complexContent>
> <xs:extension base="tns:serviceRequest">
> <xs:sequence>
> <xs:element minOccurs="0" name="xmlMessage" type="xs:string"/>
> <xs:element minOccurs="0" name="orderInputForm" type="tns:orderForm"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>*
> Please let me know how can i make sure that a particular field is
> mantadatory ??
> 
> When i tried using // @XmlElement(required = true)  private String
> xmlMessage ;
> 
> As the WSDL is generated by Apache CXF Engine , i dont have any control on
> WSDL file . So i need to make changes inside the java code itself , so that
> on to the WSDL it displays that a particular field is mantadatory
> 
> 
>  By this the  Application did not started  , It had Errors on Server console
> SEVERE: Error listenerStart Jan 12, 2012 8:34:03 PM
> org.apache.catalina.core.StandardContext start SEVERE: Context [/tata-ws]
> startup failed due to previous errors
> 
> 
> Please tell me how can i make a Field Mantadatory ??
> 
> Thanks
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-
> through-Java-Code-tp5140164p5140164.html Sent from the cxf-user mailing list
> archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: How can i make a Field Mantadatory in WSDL through Java Code

Posted by Benson Margulies <bi...@gmail.com>.
On Thu, Jan 12, 2012 at 10:11 AM, krn1231@gmail.com <kr...@gmail.com> wrote:
> I am using Apache CXF for developing Web services . This is some part of WSDL
> generated by the Apache CXF Soap Engine
>
> *<xs:complexContent>
> <xs:extension base="tns:serviceRequest">
> <xs:sequence>
> <xs:element minOccurs="0" name="xmlMessage" type="xs:string"/>
> <xs:element minOccurs="0" name="orderInputForm" type="tns:orderForm"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>*
> Please let me know how can i make sure that a particular field is
> mantadatory ??
>
> When i tried using // @XmlElement(required = true)  private String
> xmlMessage ;
>
> As the WSDL is generated by Apache CXF Engine , i dont have any control on
> WSDL file . So i need to make changes inside the java code itself , so that
> on to the WSDL it displays that a particular field is mantadatory
>
>
>  By this the  Application did not started  , It had Errors on Server console
> SEVERE: Error listenerStart Jan 12, 2012 8:34:03 PM
> org.apache.catalina.core.StandardContext start SEVERE: Context [/tata-ws]
> startup failed due to previous errors
>
>
> Please tell me how can i make a Field Mantadatory ??

We can't possibly diagnose from this much information. there must be
lots of 'previous errors' that might shed some light.


>
> Thanks
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/How-can-i-make-a-Field-Mantadatory-in-WSDL-through-Java-Code-tp5140164p5140164.html
> Sent from the cxf-user mailing list archive at Nabble.com.