문제

I would like to send and receive a SOAP message using the SAAJ API between a TCP server and client. I can easily write to a TCP socket by using the SOAPMessage class by using its method writeTo for writing into a stream but how do I read a SOAP message from a TCP stream? Which class/method might be useful?

도움이 되었습니까?

해결책

You can use javax.xml.ws.Endpoint, here is an example

@WebServiceProvider
@ServiceMode(Mode.MESSAGE)
public class SOAPServer implements Provider<SOAPMessage> {

    public SOAPMessage invoke(SOAPMessage request) {
        ... process request and create response 
        return response;
    }

    public static void main(String[] args) throws Exception {
        Endpoint.publish("http://localhost:1111/test",  new SOAPServer());
    }
}

send a request

...
URL endpoint = new URL("http://localhost:1111/test");
SOAPMessage response = connection.call(message, endpoint);
...

다른 팁

Go through this GUIDE, they explain in complete details how you can compose, send and receive SOAP message over the network using SAAJ:

http://www.ibm.com/developerworks/library/x-jaxmsoap/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top