DongJigong edited a comment on issue #2435:
URL: 
https://github.com/apache/servicecomb-java-chassis/issues/2435#issuecomment-875187421


   @chenchanglong1997 @RequestBody  receive String  xml data then parse to java 
bean. return with xml String data.
   
![image](https://user-images.githubusercontent.com/8855265/124684416-ae781a00-df01-11eb-9bb8-01dd21f866a8.png)
   
![image](https://user-images.githubusercontent.com/8855265/124684448-c51e7100-df01-11eb-856e-6f64bda88572.png)
   
   edge add a custom produceXmlProcessor 
   
   `import com.fasterxml.jackson.databind.JavaType;
   import com.kejue.edge.utils.JaxbUtils;
   import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor;
   
   import javax.ws.rs.core.MediaType;
   import java.io.InputStream;
   import java.io.OutputStream;
   public class ProduceXmlProcessor implements ProduceProcessor {
   
     @Override
     public String getName() {
       return MediaType.APPLICATION_XML;
     }
   
     @Override
     public int getOrder() {
       return 0;
     }
   
     @Override
     public void doEncodeResponse(OutputStream output, Object result) throws 
Exception {
   //    output.write(JaxbUtils.javaToXml(result).getBytes());
       output.write(result.toString().getBytes());
     }
   
     @Override
     public Object doDecodeResponse(InputStream input, JavaType type) throws 
Exception {
       return JaxbUtils.xmlToJava(type.getClass(),input);
     }
   }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to