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: [email protected]
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:[email protected]] 
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: [email protected]
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:[email protected]] 
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

Reply via email to