我从服务器获得下一个soap响应:
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:ns10="http://dom.gosuslugi.ru/schema/integration/organizations-base/" xmlns:ns11="http://dom.gosuslugi.ru/schema/integration/payments-base/" xmlns:ns12="http://dom.gosuslugi.ru/schema/integration/bills-base/" xmlns:ns13="http://dom.gosuslugi.ru/schema/integration/nsi-common/" xmlns:ns3="http://www.w3.org/2000/09/xmldsig#" xmlns:ns4="http://dom.gosuslugi.ru/schema/integration/base/" xmlns:ns5="http://dom.gosuslugi.ru/schema/integration/account-base/" xmlns:ns6="http://dom.gosuslugi.ru/schema/integration/nsi-base/" xmlns:ns7="http://dom.gosuslugi.ru/schema/integration/individual-registry-base/" xmlns:ns8="http://dom.gosuslugi.ru/schema/integration/metering-device-base/" xmlns:ns9="http://dom.gosuslugi.ru/schema/integration/organizations-registry-base/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ns4:ResultHeader>
<ns4:Date>2016-12-16T06:11:51.056+03:00</ns4:Date>
<ns4:MessageGUID>4bcfb149-fa6e-4af4-81f0-c241a88eda0e</ns4:MessageGUID>
</ns4:ResultHeader>
</soap:Header>
<soap:Body>
<ns13:exportNsiItemResult Id="signed-data-container" ns4:version="10.0.1.2"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="xmldsig-857eef84-0d64-428d-b36a-1276d6789a36"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411"/><ds:Reference URI="#signed-data-container"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gostr3411"/><ds:DigestValue>Rh1Xtyv9/5uYNZHhgpZ111+z5eW9tt1jK9PKhMUUg9k=</ds:DigestValue></ds:Reference><ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#xmldsig-857eef84-0d64-428d-b36a-1276d6789a36-signedprops"><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gostr3411"/><ds:DigestValue>C1JcCNbCHhI3hMQwbvTqaFDIVOAvdco5hBFvJ4N6jrk=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>pRO2xuJdNgljYXrxvCN8HOEPnnm5pJmirmJNWloak0cfTzwoJeLCpMVpsUoSogoS6JAl4wuQtBU71WTyTHivSA==</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIIDAjCCArGgAwIBAgITEgAVyRWEZR3kx8QM8wAAABXJFTAIBgYqhQMCAgMwfzEjMCEGCSqGSIb3DQEJARYUc3VwcG9ydEBjcnlwdG9wcm8ucnUxCzAJBgNVBAYTAlJVMQ8wDQYDVQQHEwZNb3Njb3cxFzAVBgNVBAoTDkNSWVBUTy1QUk8gTExDMSEwHwYDVQQDExhDUllQVE8tUFJPIFRlc3QgQ2VudGVyIDIwHhcNMTYxMDA0MTcwMjIzWhcNMTcwMTA0MTcxMjIzWjARMQ8wDQYDVQQDDAZUUzEwMDQwYzAcBgYqhQMCAhMwEgYHKoUDAgIkAAYHKoUDAgIeAQNDAARAT5RavuYVtUbVgxrp9M+gs6HT0z1osAFPyIe9bvz28L0qaRvof5+RBbfxq2tF2gRLsy6Wp+MGnM1IFH/+6ls2FaOCAXAwggFsMA4GA1UdDwEB/wQEAwIE8DATBgNVHSUEDDAKBggrBgEFBQcDAjAdBgNVHQ4EFgQUcLAKkPNPMWtH4wfDTUUsQJrKblkwHwYDVR0jBBgwFoAUFTF8sI0a3mbXFZxJUpcXJLkBeoMwWQYDVR0fBFIwUDBOoEygSoZIaHR0cDovL3Rlc3RjYS5jcnlwdG9wcm8ucnUvQ2VydEVucm9sbC9DUllQVE8tUFJPJTIwVGVzdCUyMENlbnRlciUyMDIuY3JsMIGpBggrBgEFBQcBAQSBnDCBmTBhBggrBgEFBQcwAoZVaHR0cDovL3Rlc3RjYS5jcnlwdG9wcm8ucnUvQ2VydEVucm9sbC90ZXN0LWNhLTIwMTRfQ1JZUFRPLVBSTyUyMFRlc3QlMjBDZW50ZXIlMjAyLmNydDA0BggrBgEFBQcwAYYoaHR0cDovL3Rlc3RjYS5jcnlwdG9wcm8ucnUvb2NzcC9vY3NwLnNyZjAIBgYqhQMCAgMDQQBcn3tilZhzT0vG7xo22x8bZCsywF9RZTQt9q+HGFfcDz4wfyWEV+gxY09C4PA0XcWwxD9GTZo8RDGP4Q+FSt1s</ds:X509Certificate></ds:X509Data></ds:KeyInfo><ds:Object><xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="#xmldsig-857eef84-0d64-428d-b36a-1276d6789a36"><xades:SignedProperties Id="xmldsig-857eef84-0d64-428d-b36a-1276d6789a36-signedprops"><xades:SignedSignatureProperties><xades:SigningTime>2016-12-16T06:11:51.058+03:00</xades:SigningTime><xades:SigningCertificate><xades:Cert><xades:CertDigest><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#gostr3411"/><ds:DigestValue>pFLpW6kFUrUxiIfnFF4T/5yuhme2WuUjmclY/17ZNKY=</ds:DigestValue></xades:CertDigest><xades:IssuerSerial><ds:X509IssuerName>cn=CRY Test Center 2,o=CRY LLC,l=Teheran,c=TN,1.2.840.113549.1.9.1=support@3pro.ru</ds:X509IssuerName><ds:X509SerialNumber>401420826789807232416437193949005597730261269</ds:X509SerialNumber></xades:IssuerSerial></xades:Cert></xades:SigningCertificate></xades:SignedSignatureProperties></xades:SignedProperties></xades:QualifyingProperties></ds:Object></ds:Signature>
<ns13:NsiItem>
<ns6:NsiItemRegistryNumber>10</ns6:NsiItemRegistryNumber>
<ns6:Created>2016-12-16T06:11:51.054+03:00</ns6:Created>
<ns6:NsiElement>
<ns6:Code>2</ns6:Code>
<ns6:GUID>53907977-1ecc-43e7-a152-749176455cb9</ns6:GUID>
<ns6:Modified>2015-01-27T21:06:45.029+03:00</ns6:Modified>
<ns6:IsActual>true</ns6:IsActual>
<ns6:NsiElementField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:NsiElementStringFieldType">
<ns6:Name>face</ns6:Name>
<ns6:Value>Nope</ns6:Value>
</ns6:NsiElementField>
</ns6:NsiElement>
<ns6:NsiElement>
<ns6:Code>3</ns6:Code>
<ns6:GUID>dcb55ce6-f3f1-4e83-ac19-b78086f3ab38</ns6:GUID>
<ns6:Modified>2015-01-27T21:06:47.913+03:00</ns6:Modified>
<ns6:IsActual>true</ns6:IsActual>
<ns6:NsiElementField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:NsiElementStringFieldType">
<ns6:Name>face</ns6:Name>
<ns6:Value>Aim</ns6:Value>
</ns6:NsiElementField>
</ns6:NsiElement>
<ns6:NsiElement>
<ns6:Code>4</ns6:Code>
<ns6:GUID>6829c60c-f057-4311-a517-fd3cdaa717a3</ns6:GUID>
<ns6:Modified>2015-01-27T21:06:47.913+03:00</ns6:Modified>
<ns6:IsActual>true</ns6:IsActual>
<ns6:NsiElementField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:NsiElementStringFieldType">
<ns6:Name>face</ns6:Name>
<ns6:Value>Owner</ns6:Value>
</ns6:NsiElementField>
</ns6:NsiElement>
<ns6:NsiElement>
<ns6:Code>1</ns6:Code>
<ns6:GUID>12d10574-32a3-40af-a4dc-988f6e873bc2</ns6:GUID>
<ns6:Modified>2015-01-27T21:06:45.029+03:00</ns6:Modified>
<ns6:IsActual>true</ns6:IsActual>
<ns6:NsiElementField xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:NsiElementStringFieldType">
<ns6:Name>face</ns6:Name>
<ns6:Value>Not Owner</ns6:Value>
</ns6:NsiElementField>
</ns6:NsiElement>
</ns13:NsiItem>
</ns13:exportNsiItemResult>
</soap:Body>
为什么当我尝试使用jax-ws 2.2.10版本解组它时,如下所示:
res = unmarshaller.unmarshal(soapResponse.getSOAPBody().extractContentAsDocument());
我得到了这个例外:
java.lang.IllegalArgumentException: prefix ns6 is not bound to a namespace
at com.sun.xml.bind.DatatypeConverterImpl._parseQName(DatatypeConverterImpl.java:364)
at com.sun.xml.bind.v2.runtime.unmarshaller.XsiTypeLoader.parseXsiType(XsiTypeLoader.java:96)
at com.sun.xml.bind.v2.runtime.unmarshaller.XsiTypeLoader.startElement(XsiTypeLoader.java:74)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:576)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:555)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:168)
我检查了我的另一个肥皂请求,它们都工作正常。我已经在Java 1.8,1.5 JDK上检查了这个问题,而且我也遇到了同样的错误。 我还检查了所有映射类,它们都包含XML中命名空间的类型。
答案 0 :(得分:0)
我的错误在于以错误的方式进行解组。我有 解组完整的soap消息,包括带有命名空间的Envelope部分,而不仅仅是soap部分的SOAP消息。 因此我得到“前缀ns6未绑定到命名空间”