You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by cantalou89 <ca...@gmail.com> on 2012/10/12 03:17:01 UTC

cxf namespace

deal all:
i have a problem about the customize namespace,
i public a webservice interface below:

@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
@EndpointProperty(key = "soap.no.validate.parts", value = "true") 
public interface UserOrderServer {

   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ;
}

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {
...
}

this interface can handle the soap message like below. the subscribeServCfmReq is without namespace,
<ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

and the client send a message like below,the subscribeServCfmReq is with namespace
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
<ns2:subscribeServCfmReq>
<ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
<ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
<ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
</ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
i try to use StaxTransformFeature  with expression "<entry key="{http://www.chinamobile.com/vgop/serviceorder/v1_0}subscribeServCfmReq" value="subscribeServCfmReq" /> " , and then it works fine,but i want to modify the annotataion to meet the message, not StaxTransformFeature , is it any way to do? 
thanks




cantalou89

Re: cxf namespace

Posted by Daniel Kulp <dk...@apache.org>.
Because the child elements are in different namespaces, this is likely going to be a bit difficult.

You can TRY doing:

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {

@XmlElement(name="msgTransactionID", namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0/common")
public String getMsgTransactionID() {
return msgTransactionID;
}
...
}

to force the namespace on each element, but I'm not sure that will work.   You can also try using XmlElementRef instead of XmlElement, but again, I'm not sure that will work without and ObjectFactory.   

Another option MAY be to put the SubscribeServCfmReq type into the "common" namespace via it's XmlType annotation.   You could try that.


Honestly, the best option may be to create a schema for this (two schemas, one for http://www.chinamobile.com/vgop/serviceorder/v1_0 and one for http://www.chinamobile.com/vgop/serviceorder/v1_0/common)  and run the wsdl2java or jaxb xic things on it to see what it generates for this.


Dan




On Oct 11, 2012, at 9:17 PM, cantalou89 <ca...@gmail.com> wrote:

> deal all:
> i have a problem about the customize namespace,
> i public a webservice interface below:
> 
> @WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
> @EndpointProperty(key = "soap.no.validate.parts", value = "true") 
> public interface UserOrderServer {
> 
>   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
>   @WebMethod(operationName="subscribeServCfm")
>   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ;
> }
> 
> @XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
> public class SubscribeServCfmReq {
> ...
> }
> 
> this interface can handle the soap message like below. the subscribeServCfmReq is without namespace,
> <ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
> <subscribeServCfmReq>
> <cfmResult>00</cfmResult>
> <msgTransactionID>qq</msgTransactionID>
> <oprTime>123</oprTime>
> </subscribeServCfmReq>
> </ns3:subscribeServCfm>
> 
> and the client send a message like below,the subscribeServCfmReq is with namespace
> <ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
> <ns2:subscribeServCfmReq>
> <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
> <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
> <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
> </ns2:subscribeServCfmReq>
> </ns2:subscribeServCfm>
> i try to use StaxTransformFeature  with expression "<entry key="{http://www.chinamobile.com/vgop/serviceorder/v1_0}subscribeServCfmReq" value="subscribeServCfmReq" /> " , and then it works fine,but i want to modify the annotataion to meet the message, not StaxTransformFeature , is it any way to do? 
> thanks
> 
> 
> 
> 
> cantalou89

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: RE: cxf namespace

Posted by cantalou89 <ca...@gmail.com>.
Thanks for your reply , and your advice works fine.
But there is a bit diferent in the configuration . I set @javax.xml.bind.annotation.XmlSchema annotations in endpoint service package-info.java not in JAXB  package-info.java .
Thanks Andrei Shakirin.



cantalou89

From: Andrei Shakirin
Date: 2012-10-12 23:43
To: users@cxf.apache.org
CC: cantalou89
Subject: RE: RE: cxf namespace
Hi,
Ø  is there a way to add namespace for subscribeServCfmReq param in my interface configuration?
Sure: but not in interface, you should do it in schema on the service side or directly in JAXB package-info.java annotations.
 
You should either define elementFormDefault="qualified" in schema element:
 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:tns="http://customerservice.example.com/" 
                attributeFormDefault="unqualified" 
                elementFormDefault="qualified" 
                targetNamespace="http://customerservice.example.com/">
and regenerate your JAXB objects;
 
or directly set @javax.xml.bind.annotation.XmlSchema(namespace = "http://customerservice.example.com/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
in package-info.java
 
After it your service will accept full qualified elements:
 
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0"> 
    <ns2:subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
 
Regards,
Andrei
 
From: cantalou89 [mailto:cantalou89@gmail.com] 
Sent: Freitag, 12. Oktober 2012 16:37
To: users
Cc: Andrei Shakirin
Subject: Re: RE: cxf namespace
 
thanks your reply, 
i am sorry for my befor problem description,it is not correct completely,
i want to receive a message like below , because client sends the fiexed soap message format and we can not modify it:
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0"> 
    <ns2:subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
 
now my server can handle message below :
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0"> 
    <subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </subscribeServCfmReq>
</ns2:subscribeServCfm>
my publiced interface will throw exception if i did not replace element <ns2:subscribeServCfmReq> of <subscribeServCfmReq>.
i am confused , subscribeServCfm conbines with the namespace , but subscribeServCfmReq is not(althought i have add @XmlType namespace in t the class ) ? so that i  have to use StaxTransformFeature  to replace <ns2:subscribeServCfmReq> by <subscribeServCfmReq> . is there a way to add namespace for subscribeServCfmReq param in my interface configuration?
 
@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public interface UserOrderServer {
 
   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ; 
}
 
@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {
 
@XmlElement(namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0/common")
public String getMsgTransactionID() {
return msgTransactionID;
}
...
}
 



cantalou89
From: Andrei Shakirin
Date: 2012-10-12 21:03
To: users@cxf.apache.org
CC: cantalou89
Subject: RE: cxf namespace
Hi,
 
I guess you can achieve it by setting elementFormDefault to unqualified in your schema:
 
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:your="http://www.chinamobile.com/vgop/serviceorder/v1_0">
...
 
Than you will get the namespace prefix only in the first tag:
<ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>
 
In the same way it should work by @XmlSchema annotation in your package-info.java:
 @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2002/03/xkms#", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED)
 
Hope it helps.
 
Regards,
Andrei.
 
-----Original Message-----
From: cantalou89 [mailto:cantalou89@gmail.com] 
Sent: Freitag, 12. Oktober 2012 03:17
To: users
Subject: cxf namespace
 
deal all:
i have a problem about the customize namespace, i public a webservice interface below:
 
@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
@EndpointProperty(key = "soap.no.validate.parts", value = "true") public interface UserOrderServer {
 
   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ; }
 
@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {
...
}
 
this interface can handle the soap message like below. the subscribeServCfmReq is without namespace, <ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>
 
and the client send a message like below,the subscribeServCfmReq is with namespace <ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
<ns2:subscribeServCfmReq>
<ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
<ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
<ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
</ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
i try to use StaxTransformFeature  with expression "<entry key="{http://www.chinamobile.com/vgop/serviceorder/v1_0}subscribeServCfmReq" value="subscribeServCfmReq" /> " , and then it works fine,but i want to modify the annotataion to meet the message, not StaxTransformFeature , is it any way to do? 
thanks
 
 
 
 
cantalou89

RE: RE: cxf namespace

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

Ø  is there a way to add namespace for subscribeServCfmReq param in my interface configuration?
Sure: but not in interface, you should do it in schema on the service side or directly in JAXB package-info.java annotations.

You should either define elementFormDefault="qualified" in schema element:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:tns="http://customerservice.example.com/"
                attributeFormDefault="unqualified"
                elementFormDefault="qualified"
                targetNamespace="http://customerservice.example.com/">
and regenerate your JAXB objects;

or directly set @javax.xml.bind.annotation.XmlSchema(namespace = "http://customerservice.example.com/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
in package-info.java

After it your service will accept full qualified elements:

<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
    <ns2:subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>

Regards,
Andrei

From: cantalou89 [mailto:cantalou89@gmail.com]
Sent: Freitag, 12. Oktober 2012 16:37
To: users
Cc: Andrei Shakirin
Subject: Re: RE: cxf namespace

thanks your reply,
i am sorry for my befor problem description,it is not correct completely,
i want to receive a message like below , because client sends the fiexed soap message format and we can not modify it:
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
    <ns2:subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>

now my server can handle message below :
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
    <subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </subscribeServCfmReq>
</ns2:subscribeServCfm>
my publiced interface will throw exception if i did not replace element <ns2:subscribeServCfmReq> of <subscribeServCfmReq>.
i am confused , subscribeServCfm conbines with the namespace , but subscribeServCfmReq is not(althought i have add @XmlType namespace in t the class ) ? so that i  have to use StaxTransformFeature  to replace <ns2:subscribeServCfmReq> by <subscribeServCfmReq> . is there a way to add namespace for subscribeServCfmReq param in my interface configuration?

@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public interface UserOrderServer {

   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ;
}

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {

@XmlElement(namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0/common")
public String getMsgTransactionID() {
return msgTransactionID;
}
...
}

________________________________
cantalou89
From: Andrei Shakirin<ma...@talend.com>
Date: 2012-10-12 21:03
To: users@cxf.apache.org<ma...@cxf.apache.org>
CC: cantalou89<ma...@gmail.com>
Subject: RE: cxf namespace
Hi,

I guess you can achieve it by setting elementFormDefault to unqualified in your schema:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:your="http://www.chinamobile.com/vgop/serviceorder/v1_0">
...

Than you will get the namespace prefix only in the first tag:
<ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

In the same way it should work by @XmlSchema annotation in your package-info.java:
 @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2002/03/xkms#", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED)

Hope it helps.

Regards,
Andrei.

-----Original Message-----
From: cantalou89 [mailto:cantalou89@gmail.com]
Sent: Freitag, 12. Oktober 2012 03:17
To: users
Subject: cxf namespace

deal all:
i have a problem about the customize namespace, i public a webservice interface below:

@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
@EndpointProperty(key = "soap.no.validate.parts", value = "true") public interface UserOrderServer {

   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ; }

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {
...
}

this interface can handle the soap message like below. the subscribeServCfmReq is without namespace, <ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

and the client send a message like below,the subscribeServCfmReq is with namespace <ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
<ns2:subscribeServCfmReq>
<ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
<ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
<ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
</ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
i try to use StaxTransformFeature  with expression "<entry key="{http://www.chinamobile.com/vgop/serviceorder/v1_0}subscribeServCfmReq" value="subscribeServCfmReq" /> " , and then it works fine,but i want to modify the annotataion to meet the message, not StaxTransformFeature , is it any way to do?
thanks




cantalou89

Re: RE: cxf namespace

Posted by cantalou89 <ca...@gmail.com>.
thanks your reply, 
i am sorry for my befor problem description,it is not correct completely,
i want to receive a message like below , because client sends the fiexed soap message format and we can not modify it:
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
    <ns2:subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>

now my server can handle message below :
<ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0"> 
    <subscribeServCfmReq>
       <ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
       <ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
       <ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
   </subscribeServCfmReq>
</ns2:subscribeServCfm>
my publiced interface will throw exception if i did not replace element <ns2:subscribeServCfmReq> of <subscribeServCfmReq>.
i am confused , subscribeServCfm conbines with the namespace , but subscribeServCfmReq is not(althought i have add @XmlType namespace in t the class ) ? so that i  have to use StaxTransformFeature  to replace <ns2:subscribeServCfmReq> by <subscribeServCfmReq> . is there a way to add namespace for subscribeServCfmReq param in my interface configuration?

@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public interface UserOrderServer {

   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ; 
}

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {

@XmlElement(namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0/common")
public String getMsgTransactionID() {
return msgTransactionID;
}
...
}




cantalou89
From: Andrei Shakirin
Date: 2012-10-12 21:03
To: users@cxf.apache.org
CC: cantalou89
Subject: RE: cxf namespace
Hi,

I guess you can achieve it by setting elementFormDefault to unqualified in your schema:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:your="http://www.chinamobile.com/vgop/serviceorder/v1_0">
...

Than you will get the namespace prefix only in the first tag:
<ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

In the same way it should work by @XmlSchema annotation in your package-info.java:
 @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2002/03/xkms#", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED)

Hope it helps.

Regards,
Andrei.

-----Original Message-----
From: cantalou89 [mailto:cantalou89@gmail.com] 
Sent: Freitag, 12. Oktober 2012 03:17
To: users
Subject: cxf namespace

deal all:
i have a problem about the customize namespace, i public a webservice interface below:

@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
@EndpointProperty(key = "soap.no.validate.parts", value = "true") public interface UserOrderServer {

   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ; }

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {
...
}

this interface can handle the soap message like below. the subscribeServCfmReq is without namespace, <ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

and the client send a message like below,the subscribeServCfmReq is with namespace <ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
<ns2:subscribeServCfmReq>
<ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
<ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
<ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
</ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
i try to use StaxTransformFeature  with expression "<entry key="{http://www.chinamobile.com/vgop/serviceorder/v1_0}subscribeServCfmReq" value="subscribeServCfmReq" /> " , and then it works fine,but i want to modify the annotataion to meet the message, not StaxTransformFeature , is it any way to do? 
thanks




cantalou89

RE: cxf namespace

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

I guess you can achieve it by setting elementFormDefault to unqualified in your schema:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:your="http://www.chinamobile.com/vgop/serviceorder/v1_0">
...

Than you will get the namespace prefix only in the first tag:
<ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

In the same way it should work by @XmlSchema annotation in your package-info.java:
 @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2002/03/xkms#", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED)

Hope it helps.

Regards,
Andrei.

-----Original Message-----
From: cantalou89 [mailto:cantalou89@gmail.com] 
Sent: Freitag, 12. Oktober 2012 03:17
To: users
Subject: cxf namespace

deal all:
i have a problem about the customize namespace, i public a webservice interface below:

@WebService(targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
@EndpointProperty(key = "soap.no.validate.parts", value = "true") public interface UserOrderServer {

   @ResponseWrapper(className="com.funo.ehealth.SubscribeServCfmResp",targetNamespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
   @WebMethod(operationName="subscribeServCfm")
   public SubscribeServCfmResp subscribeServCfm(@WebParam(name="subscribeServCfmReq")SubscribeServCfmReq subscribeServCfmReq) ; }

@XmlType(name="subscribeServCfmReq",namespace="http://www.chinamobile.com/vgop/serviceorder/v1_0")
public class SubscribeServCfmReq {
...
}

this interface can handle the soap message like below. the subscribeServCfmReq is without namespace, <ns3:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0" xmlns:ns3="http://main.ehealth.funo.com/">
<subscribeServCfmReq>
<cfmResult>00</cfmResult>
<msgTransactionID>qq</msgTransactionID>
<oprTime>123</oprTime>
</subscribeServCfmReq>
</ns3:subscribeServCfm>

and the client send a message like below,the subscribeServCfmReq is with namespace <ns2:subscribeServCfm xmlns:ns2="http://www.chinamobile.com/vgop/serviceorder/v1_0">
<ns2:subscribeServCfmReq>
<ns1:msgTransactionID xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">555</ns1:msgTransactionID>
<ns1:oprTime xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">20121011094323</ns1:oprTime>
<ns1:cfmResult xmlns:ns1="http://www.chinamobile.com/vgop/serviceorder/v1_0/common">00</ns1:cfmResult>
</ns2:subscribeServCfmReq>
</ns2:subscribeServCfm>
i try to use StaxTransformFeature  with expression "<entry key="{http://www.chinamobile.com/vgop/serviceorder/v1_0}subscribeServCfmReq" value="subscribeServCfmReq" /> " , and then it works fine,but i want to modify the annotataion to meet the message, not StaxTransformFeature , is it any way to do? 
thanks




cantalou89