简体   繁体   中英

Return XML document Jax-WS

I have Web Service (Jax-WS), which uses internal service (further IS ) to connect to some URL via GET method. IS connects to specific url and gets response. Returned data(in xml format) might be different depending on parameters passed. Here is one important point! By difference I mean the difference of the structure of the returned xml , ie with one set of parametres we get one xml, with another set of parameters we get another, different xml (structure is different). My main goal is to ReSend this response (another jobs are done) to client calling my web service. Here my web service works as brigde. Suppose I can't use JaxB, cause I get different xml structured data(there nothing is common between them). My question is How Can I solve it ? How Can I resend everything came to me to client? Without unmarshalling it . Is it possible to do it with stream? I am able to get returned data in InputStream or String

@Slf4j
@WebService(name = CCServiceWS.WS_NAME,
        serviceName = CCWS.WS_SERVICE_NAME,
        portName = CCWS.WS_PORT_NAME,
        targetNamespace = CCWS.WS_NAMESPACE)
@Logged
@Component
public class CCWSImpl implements CCServiceWS {

    @Autowired
    CCService ccService;

    @Override
    public Object reserve(@XmlElement(required = true) @NotNull String m1,
                                                   @XmlElement(required = true) @NotNull String m2,
                                                   @XmlElement(required = true) @NotNull Integer amount)  {
        return ccService.reserve(m1, m2, amount);
    }
}

My internal Service

@Slf4j
@Component
public class CCService   {

    @Override
    public Object reserve(@NotNull String m1, @NotNull String m2, @NotNull Integer amount)  {

            URL url = new URL("http://example.com?a=5&v=56");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            inputStream = connection.getInputStream();
            // Here I get input stream        
    }
}

Why don't you send it as String ? No matter what comes to you , you can send it to clients

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM