编程

当前位置:澳门新莆京娱乐官网 > 编程 > java中SOAPMessage 消息SOAP部分加xml头的API函数

java中SOAPMessage 消息SOAP部分加xml头的API函数

来源:http://www.drgigabytes.com 作者:澳门新莆京娱乐官网 时间:2019-12-28 22:24

奥门新萄京83855com 1

想在SOAP部分的env:Envelope节点上方,加上一行?xmlversion="1.0"encoding="UTF-8"?。就像xml文件中一样,我一下没找到API,谁告诉调用什么函数加。奥门新萄京83855com,我的java代码发送数据片段:

SOAPConnectionFactorysoapConnectionFactory=SOAPConnectionFactory.newInstance();soapConnection=soapConnectionFactory.createConnection();//创建SOAPMessageSOAPMessagesoapMessage=createSoapMessage(soapRequestElem,needsAuthentification);//发送soapResponse=soapConnection.call(soapMessage,soapUri);

创建SOAPMessage的具体函数:

protectedSOAPMessagecreateSoapMessage(ObjectsoapRequestElem,booleanneedAuthentification)throwsSOAPException,ParserConfigurationException,JAXBException{MessageFactorymessageFactory=MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);SOAPMessagesoapMessage=messageFactory.createMessage();Documentdocument=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();Marshallermarshaller=JAXBContext.newInstance(soapRequestElem.getClass()).createMarshaller();marshaller.marshal(soapRequestElem,document);soapMessage.getSOAPBody().addDocument(document);//if(needAuthentification)createSoapHeader(soapMessage);soapMessage.saveChanges();returnsoapMessage;}

具体发送的数据格式:

POST/onvif/device_serviceHTTP/1.1Accept:application/soap+xml,text/html,image/gif,image/jpeg,*;q=.2,*/*;q=.2Content-Type:application/soap+xml;charset=utf-8Cache-Control:no-cachePragma:no-cacheUser-Agent:Java/1.7.0_67Host:192.168.168.139Connection:keep-aliveContent-Length:851env:Envelopexmlns:env=""xmlns:wsse=""xmlns:wsu=""env:Headerwsse:Securitywsse:UsernameTokenwsse:Usernameadmin/wsse:Usernamewsse:PasswordType="#PasswordDigest"c1v/qUvoMJA9xdmutnmvBTgzPzs=/wsse:Passwordwsse:NonceEncodingType="#Base64Binary"LTEyOTg3NDM5NzA=/wsse:Noncewsu:Created2019-11-8T03:58:25Z/wsu:Created/wsse:UsernameToken/wsse:Security/env:Headerenv:BodyGetCapabilitiesxmlns=""//env:Body/env:Envelope

本文由澳门新莆京娱乐官网发布于编程,转载请注明出处:java中SOAPMessage 消息SOAP部分加xml头的API函数

关键词:

上一篇:springboot配置https启动总是出现端口占用

下一篇:没有了