码迷,mamicode.com
首页 > 其他好文 > 详细

cxf返回的报文,命名空间无前缀

时间:2015-12-24 00:21:32      阅读:2789      评论:0      收藏:0      [点我收藏+]

标签:

cxf框架做的服务端接收请求并响应。

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
  <soap:Body xmlns="http://www.example.org/stock">
    <GetStockPriceResponse>
      <Price>34.5</m:Price>
    </GetStockPriceResponse>
  </soap:Body>
</soap:Envelope>

 

希望得到的返回应该是:

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPriceResponse>
      <m:Price>34.5</m:Price>
    </m:GetStockPriceResponse>
  </soap:Body>
</soap:Envelope>

 

找了很久,最后在自动生成的ObjectFactory文件中解决了。

将第367行 namespace 里面设为“”即可。

  1 package com.haiyisoft.hyoms.wbs.pubMVFault;
  2 
  3 import javax.xml.bind.JAXBElement;
  4 import javax.xml.bind.annotation.XmlElementDecl;
  5 import javax.xml.bind.annotation.XmlRegistry;
  6 import javax.xml.namespace.QName;
  7 
  8 
  9 /**
 10  * This object contains factory methods for each 
 11  * Java content interface and Java element interface 
 12  * generated in the com.haiyisoft.hyoms.wbs.pubMVFault package. 
 13  * <p>An ObjectFactory allows you to programatically 
 14  * construct new instances of the Java representation 
 15  * for XML content. The Java representation of XML 
 16  * content can consist of schema derived interfaces 
 17  * and classes representing the binding of schema 
 18  * type definitions, element declarations and model 
 19  * groups.  Factory methods for each of these are 
 20  * provided in this class.
 21  * 
 22  */
 23 @XmlRegistry
 24 public class ObjectFactory {
 25 
 26     private final static QName _PublishMVFaultRepairWorkResponse_QNAME = new QName("http://pdjyh.soa.csg.cn", "PublishMVFaultRepairWorkResponse");
 27     private final static QName _EventMessage_QNAME = new QName("http://pdjyh.soa.csg.cn", "EventMessage");
 28     private final static QName _PublishMVFaultRepairWorkRequest_QNAME = new QName("http://pdjyh.soa.csg.cn", "PublishMVFaultRepairWorkRequest");
 29     private final static QName _RequestMessage_QNAME = new QName("http://pdjyh.soa.csg.cn", "RequestMessage");
 30     private final static QName _ResponseMessage_QNAME = new QName("http://pdjyh.soa.csg.cn", "ResponseMessage");
 31 
 32     /**
 33      * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.haiyisoft.hyoms.wbs.pubMVFault
 34      * 
 35      */
 36     public ObjectFactory() {
 37     }
 38 
 39     /**
 40      * Create an instance of {@link ObjQueryParam }
 41      * 
 42      */
 43     public ObjQueryParam createObjQueryParam() {
 44         return new ObjQueryParam();
 45     }
 46 
 47     /**
 48      * Create an instance of {@link PublishMVFaultRepairWorkResponseType }
 49      * 
 50      */
 51     public PublishMVFaultRepairWorkResponseType createPublishMVFaultRepairWorkResponseType() {
 52         return new PublishMVFaultRepairWorkResponseType();
 53     }
 54 
 55     /**
 56      * Create an instance of {@link EventMessageType }
 57      * 
 58      */
 59     public EventMessageType createEventMessageType() {
 60         return new EventMessageType();
 61     }
 62 
 63     /**
 64      * Create an instance of {@link PublishMVFaultRepairWorkRequestType }
 65      * 
 66      */
 67     public PublishMVFaultRepairWorkRequestType createPublishMVFaultRepairWorkRequestType() {
 68         return new PublishMVFaultRepairWorkRequestType();
 69     }
 70 
 71     /**
 72      * Create an instance of {@link RequestMessageType }
 73      * 
 74      */
 75     public RequestMessageType createRequestMessageType() {
 76         return new RequestMessageType();
 77     }
 78 
 79     /**
 80      * Create an instance of {@link ResponseMessageType }
 81      * 
 82      */
 83     public ResponseMessageType createResponseMessageType() {
 84         return new ResponseMessageType();
 85     }
 86 
 87     /**
 88      * Create an instance of {@link ErrorType }
 89      * 
 90      */
 91     public ErrorType createErrorType() {
 92         return new ErrorType();
 93     }
 94 
 95     /**
 96      * Create an instance of {@link Substation }
 97      * 
 98      */
 99     public Substation createSubstation() {
100         return new Substation();
101     }
102 
103     /**
104      * Create an instance of {@link Operation }
105      * 
106      */
107     public Operation createOperation() {
108         return new Operation();
109     }
110 
111     /**
112      * Create an instance of {@link Attachment }
113      * 
114      */
115     public Attachment createAttachment() {
116         return new Attachment();
117     }
118 
119     /**
120      * Create an instance of {@link DispatchingTroubleTicketMirdItem }
121      * 
122      */
123     public DispatchingTroubleTicketMirdItem createDispatchingTroubleTicketMirdItem() {
124         return new DispatchingTroubleTicketMirdItem();
125     }
126 
127     /**
128      * Create an instance of {@link OperationSet }
129      * 
130      */
131     public OperationSet createOperationSet() {
132         return new OperationSet();
133     }
134 
135     /**
136      * Create an instance of {@link ErpOrganisation }
137      * 
138      */
139     public ErpOrganisation createErpOrganisation() {
140         return new ErpOrganisation();
141     }
142 
143     /**
144      * Create an instance of {@link MVFaultRepairWork }
145      * 
146      */
147     public MVFaultRepairWork createMVFaultRepairWork() {
148         return new MVFaultRepairWork();
149     }
150 
151     /**
152      * Create an instance of {@link ErpPerson }
153      * 
154      */
155     public ErpPerson createErpPerson() {
156         return new ErpPerson();
157     }
158 
159     /**
160      * Create an instance of {@link TroubleTicketItem }
161      * 
162      */
163     public TroubleTicketItem createTroubleTicketItem() {
164         return new TroubleTicketItem();
165     }
166 
167     /**
168      * Create an instance of {@link EquipmentFault }
169      * 
170      */
171     public EquipmentFault createEquipmentFault() {
172         return new EquipmentFault();
173     }
174 
175     /**
176      * Create an instance of {@link OptionType }
177      * 
178      */
179     public OptionType createOptionType() {
180         return new OptionType();
181     }
182 
183     /**
184      * Create an instance of {@link DocErpPersonRole }
185      * 
186      */
187     public DocErpPersonRole createDocErpPersonRole() {
188         return new DocErpPersonRole();
189     }
190 
191     /**
192      * Create an instance of {@link FaultMessageType }
193      * 
194      */
195     public FaultMessageType createFaultMessageType() {
196         return new FaultMessageType();
197     }
198 
199     /**
200      * Create an instance of {@link Circuit }
201      * 
202      */
203     public Circuit createCircuit() {
204         return new Circuit();
205     }
206 
207     /**
208      * Create an instance of {@link DocOrgRole }
209      * 
210      */
211     public DocOrgRole createDocOrgRole() {
212         return new DocOrgRole();
213     }
214 
215     /**
216      * Create an instance of {@link Equipment }
217      * 
218      */
219     public Equipment createEquipment() {
220         return new Equipment();
221     }
222 
223     /**
224      * Create an instance of {@link FaultCode }
225      * 
226      */
227     public FaultCode createFaultCode() {
228         return new FaultCode();
229     }
230 
231     /**
232      * Create an instance of {@link SwtichingPowerSupply }
233      * 
234      */
235     public SwtichingPowerSupply createSwtichingPowerSupply() {
236         return new SwtichingPowerSupply();
237     }
238 
239     /**
240      * Create an instance of {@link OutageEquipment }
241      * 
242      */
243     public OutageEquipment createOutageEquipment() {
244         return new OutageEquipment();
245     }
246 
247     /**
248      * Create an instance of {@link DispatchingTroubleTicketMirdList }
249      * 
250      */
251     public DispatchingTroubleTicketMirdList createDispatchingTroubleTicketMirdList() {
252         return new DispatchingTroubleTicketMirdList();
253     }
254 
255     /**
256      * Create an instance of {@link FaultRecord }
257      * 
258      */
259     public FaultRecord createFaultRecord() {
260         return new FaultRecord();
261     }
262 
263     /**
264      * Create an instance of {@link ReplyType }
265      * 
266      */
267     public ReplyType createReplyType() {
268         return new ReplyType();
269     }
270 
271     /**
272      * Create an instance of {@link TroubleTicketList }
273      * 
274      */
275     public TroubleTicketList createTroubleTicketList() {
276         return new TroubleTicketList();
277     }
278 
279     /**
280      * Create an instance of {@link TroubleTicket }
281      * 
282      */
283     public TroubleTicket createTroubleTicket() {
284         return new TroubleTicket();
285     }
286 
287     /**
288      * Create an instance of {@link DistributionTransformer }
289      * 
290      */
291     public DistributionTransformer createDistributionTransformer() {
292         return new DistributionTransformer();
293     }
294 
295     /**
296      * Create an instance of {@link RequestType }
297      * 
298      */
299     public RequestType createRequestType() {
300         return new RequestType();
301     }
302 
303     /**
304      * Create an instance of {@link MessageProperty }
305      * 
306      */
307     public MessageProperty createMessageProperty() {
308         return new MessageProperty();
309     }
310 
311     /**
312      * Create an instance of {@link ObjQueryParam.MRIDs }
313      * 
314      */
315     public ObjQueryParam.MRIDs createObjQueryParamMRIDs() {
316         return new ObjQueryParam.MRIDs();
317     }
318 
319     /**
320      * Create an instance of {@link ObjQueryParam.Properties }
321      * 
322      */
323     public ObjQueryParam.Properties createObjQueryParamProperties() {
324         return new ObjQueryParam.Properties();
325     }
326 
327     /**
328      * Create an instance of {@link JAXBElement }{@code <}{@link PublishMVFaultRepairWorkResponseType }{@code >}}
329      * 
330      */
331     @XmlElementDecl(namespace = "http://pdjyh.soa.csg.cn", name = "PublishMVFaultRepairWorkResponse")
332     public JAXBElement<PublishMVFaultRepairWorkResponseType> createPublishMVFaultRepairWorkResponse(PublishMVFaultRepairWorkResponseType value) {
333         return new JAXBElement<PublishMVFaultRepairWorkResponseType>(_PublishMVFaultRepairWorkResponse_QNAME, PublishMVFaultRepairWorkResponseType.class, null, value);
334     }
335 
336     /**
337      * Create an instance of {@link JAXBElement }{@code <}{@link EventMessageType }{@code >}}
338      * 
339      */
340     @XmlElementDecl(namespace = "http://pdjyh.soa.csg.cn", name = "EventMessage")
341     public JAXBElement<EventMessageType> createEventMessage(EventMessageType value) {
342         return new JAXBElement<EventMessageType>(_EventMessage_QNAME, EventMessageType.class, null, value);
343     }
344 
345     /**
346      * Create an instance of {@link JAXBElement }{@code <}{@link PublishMVFaultRepairWorkRequestType }{@code >}}
347      * 
348      */
349     @XmlElementDecl(namespace = "http://pdjyh.soa.csg.cn", name = "PublishMVFaultRepairWorkRequest")
350     public JAXBElement<PublishMVFaultRepairWorkRequestType> createPublishMVFaultRepairWorkRequest(PublishMVFaultRepairWorkRequestType value) {
351         return new JAXBElement<PublishMVFaultRepairWorkRequestType>(_PublishMVFaultRepairWorkRequest_QNAME, PublishMVFaultRepairWorkRequestType.class, null, value);
352     }
353 
354     /**
355      * Create an instance of {@link JAXBElement }{@code <}{@link RequestMessageType }{@code >}}
356      * 
357      */
358     @XmlElementDecl(namespace = "http://pdjyh.soa.csg.cn", name = "RequestMessage")
359     public JAXBElement<RequestMessageType> createRequestMessage(RequestMessageType value) {
360         return new JAXBElement<RequestMessageType>(_RequestMessage_QNAME, RequestMessageType.class, null, value);
361     }
362 
363     /**
364      * Create an instance of {@link JAXBElement }{@code <}{@link ResponseMessageType }{@code >}}
365      * 
366      */
367     @XmlElementDecl(namespace = "http://pdjyh.soa.csg.cn", name = "ResponseMessage")
368     public JAXBElement<ResponseMessageType> createResponseMessage(ResponseMessageType value) {
369         return new JAXBElement<ResponseMessageType>(_ResponseMessage_QNAME, ResponseMessageType.class, null, value);
370     }
371 
372 }

 

  

 

cxf返回的报文,命名空间无前缀

标签:

原文地址:http://www.cnblogs.com/a2sha5/p/5071626.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!