使用JAX-WS发送带有标头的SOAP请求

时间:2013-06-10 05:01:28

标签: java web-services jax-ws

我要发送的请求是: -

            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:idm="http://integration.standardandpoors.com/Schema/IDM">
               <soapenv:Header>
                   <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                   <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-23762130">
                   <wsu:Created>2013-06-09T06:00:44.733Z</wsu:Created>
                   <wsu:Expires>2013-06-09T08:00:44.733Z</wsu:Expires>
                   </wsu:Timestamp>
                   <wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="SSHA" ValueType="AccessManagerSSOSecurityToken" wsu:Id="OAMToken">TOKEN HARE</wsse:BinarySecurityToken>
                   </wsse:Security>

               </soapenv:Header>


               <soapenv:Body>
                  <idm:findUserById>
                     <applicationName>APP ID</applicationName>
                     <userId>USER ID</userId>
                  </idm:findUserById>
               </soapenv:Body>
            </soapenv:Envelope>

我目前的java代码是

            public class WsClient{

                public static void main(String[] args) throws Exception {

                    IdmService sis = new IdmService();

                    IdmWebServicePort si = sis.getIdmWebServiceImplPort();
                    WSBindingProvider bp = (WSBindingProvider)si;
                    Element node =  DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">   <wsu:Timestamp xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"Timestamp-23762130\"><wsu:Created>2013-06-09T06:00:44.733Z</wsu:Created>  <wsu:Expires>2013-06-09T08:00:44.733Z</wsu:Expires></wsu:Timestamp><wsse:BinarySecurityToken xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" EncodingType=\"SSHA\" ValueType=\"AccessManagerSSOSecurityToken\" wsu:Id=\"OAMToken\">token here</wsse:BinarySecurityToken></wsse:Security>".getBytes())).getDocumentElement();
                    bp.setOutboundHeaders(

                            Headers.create(node)

                    );



                    //si.getSecurityChallengeQuestionsAndAnswersForUser("APP NAME", "USER ID");

                    User u=si.findUserById("MSA", "test100@sandp.com");

                    System.out.println(u.getFirstName());

                }

            }
我得到的错误是: -

线程“main”中的异常java.lang.NoSuchMethodError:com.sun.xml.bind.api.JAXBRIContext.newInstance

0 个答案:

没有答案