来自C#中wsdl的Soap消息中的标题

问题描述

到目前为止,我已经使用提供的wsdl来使用没有问题的Web服务上公开的政府服务。 通过连接到服务并使用文档类,我得到了以下请求:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis- 
open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- 
wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="uuid-d5d2f565-9027-4da9-9354-8803db695be7-1"><u:Created>2020-11- 
05T07:35:56.762Z</u:Created><u:Expires>2020-11-05T07:40:56.762Z</u:Expires></u:Timestamp>
<o:BinarySecurityToken u:Id="uuid-7de78e07-4175-4b70-85a1-a153ae5b4da7-2" 
ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" 
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security- 
1.0#Base64Binary">canceled Now because it is too long</o:BinarySecurityToken>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
   <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
    <Reference URI="#uuid-d5d2f565-9027-4da9-9354-8803db695be7-1">
<Transforms>
    <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>uTP02nd8WZ5d77mUz5XZqcaFo9U=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>canceled Now because it is too long</SignatureValue><KeyInfo> 
<o:SecurityTokenReference><o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401- 
wss-x509-token-profile-1.0#X509v3" URI="#uuid-7de78e07-4175-4b70-85a1-a153ae5b4da7-2"/> 
</o:SecurityTokenReference></KeyInfo></Signature></o:Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<addDocument xmlns="http://www.sist.puglia.it/Schemas/PDD_SIST/SCATEL/FSE/">
    <document>
        <document>canceled Now because it is too long</document>
        <documentName>NameOfDocument</documentName>
    <status>Approved</status>
    </document>
    <repositoryDocumentURI><documentID>123456</documentID><localNode>localnode</localNode><regionalNode>IT-75</regionalNode></repositoryDocumentURI>
</addDocument>
</s:Body>
</s:Envelope>

但是他们给我的示例(我希望是正确的)在Header部分完全不同,Header部分中有一系列断言,但我不知道该如何插入到Header中。示例是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
    <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" saml:ID="identity-assertion" saml:IssueInstant="2020-01-08T18:24:26.000Z" saml:Version="2.0" wsu:Id="identity-assertion" xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:assertion saml-schema-assertion-2.0.xsd">
        <saml:Issuer>ClientIssuer</saml:Issuer>
        <saml:Subject>
            <saml:NameID>1234567890.mycomp.it</saml:NameID>
        </saml:Subject>
        <saml:Conditions NotBefore="2020-05-26T08:55:16Z" NotOnorAfter="2020-05-26T09:00:16Z"/>
        <saml:AuthnStatement AuthnInstant="2020-05-26T08:55:16Z">
            <saml:AuthnContext>
                <saml:AuthnContextDecl/>
                <saml:AuthenticatingAuthority/>
            </saml:AuthnContext>
        </saml:AuthnStatement>
        <saml:AttributeStatement/>
    </saml:Assertion>
    <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" saml:ID="authorization-assertion" saml:IssueInstant="2020-01-08T18:24:26.000Z" saml:Version="2.0" wsu:Id="authorization-assertion" xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:assertion saml-schema-assertion-2.0.xsd">
        <saml:Issuer>ClientIssuer</saml:Issuer>
        <saml:Subject>
            <saml:NameID>1234567890.mycomp.it</saml:NameID>
        </saml:Subject>
        <saml:Conditions NotBefore="2020-05-26T08:55:16Z" NotOnorAfter="2020-05-26T09:00:16Z"/>
        <saml:AuthzDecisionStatement Decision="Permit" Resource="https://pddasl-coll.rmmg.rsr.rupar.puglia.it:8181/aslba/IDocumentService">
            <saml:Action Namespace="http://www.sist.puglia.it/Schemas/PDD_SIST/SCATEL/FSE/">addDocument</saml:Action>
        </saml:AuthzDecisionStatement>
    </saml:Assertion>
    <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" saml:ID="applicative-assertion" saml:IssueInstant="2020-01-08T18:24:26.000Z" saml:Version="2.0" wsu:Id="applicative-assertion" xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:assertion saml-schema-assertion-2.0.xsd">
        <saml:Issuer>ClientIssuer</saml:Issuer>
        <saml:Subject>
            <saml:NameID>1234567890</saml:NameID>
        </saml:Subject>
        <saml:Conditions NotBefore="2020-05-26T08:55:16Z" NotOnorAfter="2020-05-26T08:55:16Z"/>
        <saml:AuthnStatement AuthnInstant="2020-05-26T08:55:16Z">
            <saml:AuthnContext>
                <saml:AuthnContextDecl/>
                <saml:AuthenticatingAuthority/>
            </saml:AuthnContext>
        </saml:AuthnStatement>
        <saml:AttributeStatement>
            <saml:Attribute Name="urn:oasis:names:tc:sist:1.0:subject:subject-application-id" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">program</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:sist:1.0:subject:subject-application-vendor" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">producer</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:sist:1.0:subject:subject-application-version" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">3</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:sist:1.0:subject:subject-application-nonce" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">l1x3wk1nuWr6WFZ0vTXO</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:sist:1.0:subject:subject-application-created" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2020-05-26T08:55:16Z</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:sist:1.0:subject:subject-application-digest" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">exC6bLX8oBreK1Dvx8BmZHpaoCU=</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xacml:1.0:subject:subject-id" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">05897456898</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:organization-id" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">160123</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:organization" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">ASL WORLD</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xacml:1.0:action:action-id" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">C</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xacml:2.0:subject:role" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">RIS000055</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xacml:1.0:resource:resource-id" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xsi:type="xs:string">asdert56y76u777i</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xspa:1.0:resource:hl7:type" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">223344-2</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xspa:1.0:environment:locality" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">123456 - CLIENT OF WEB SERVICE"</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xspa:1.0:resource:patient:hl7:confidentiality-code" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">false</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="urn:oasis:names:tc:xspa:1.0:resource:patient:consent" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
                <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">true</saml:AttributeValue>
            </saml:Attribute>
        </saml:AttributeStatement>
    </saml:Assertion>
    <wsa:Action xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" soapenv:mustUnderstand="1">http://www.sist.puglia.it/Schemas/PDD_SIST/SCATEL/FSE/addDocument</wsa:Action>
    <wsa:ReplyTo xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">
        <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
    </wsa:ReplyTo>
    <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">https://pddasl-coll.rmmg.rsr.rupar.puglia.it:8181/aslba/IDocumentService</wsa:To>
    <wsa:FaultTo xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">
        <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
    </wsa:FaultTo>
    <wsa:MessageID xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">uuid:F1625E20-8969-428F-8FCC-26A7EBFAE6BB</wsa:MessageID>
</s:Header>
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <addDocument xmlns="http://www.sist.puglia.it/Schemas/PDD_SIST/SCATEL/FSE/">
        <document>
            <document>canceled Now because it is too long</document>
            <documentName>doc_43139T2V1</documentName>
            <status>Approved</status>
            <binaryDocument>canceled Now because it is too long</binaryDocument>
            <binaryName>doc_43139T2V1.pdf</binaryName>
        </document>
    </addDocument>
</s:Body>
</s:Envelope>

在wsdl类中,我有一个称为 samlAssertion 的类,也许用于在Header中插入必要的行,但是我不知道如何使用它或如何将生成的行行到已经在标题自动出现的行。 我能怎么做?劝我不要使用wsdl,而要使用另一种方式?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)