-1
我正在用Java開發一個寧靜的Web服務。我的一個服務需要調用SOAP服務,爲此我需要構建一個XML請求。我的問題是「我想在一個獨立的助手類中構建這個xml文件,這是一個方便的方法嗎?」我正在使用Spring for MVC,這裏有什麼優點可以實現?Java中的最佳實踐XML請求生成器
示例pseucode;
@RestController
@RequestMapping("/rest/menu")
public class MenuController {
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> createUser(@RequestBody JSONObject userInfo){
//Here I need to make a Soap call to retrieve some information
MyXMLBuilder myXMLBuilder = new MyXMLBuilder();
String soapRequest = myXMLBuilder.build();
}}
和這裏的助手類;
public class MyXMLBuilder(){
public String build(){
//xml build implementation
}}
什麼都要的' 'build()''方法呢?序列化一些objets到XML? –
是的,正好將對象序列化爲xml。 – benjamin
你的對象被註釋了嗎? –