Формат MTOM мыльного сопоставления на стороне сервера (граница MIME) - PullRequest
0 голосов
/ 11 октября 2019

Я пытаюсь найти способ написать веб-метод, который может обрабатывать мыльный формат MTOM. Запрос Soap имеет заголовок и тело, а затем границу MIME

   POST /v2/document/soap HTTP/1.1
Host: doctest.applyonline.com.au
User-Agent: curl/7.43.0
Accept: */*
Content-Type: multipart/related; boundary="MIMEBoundary_d2d526d5b9a7f9dba48a297330bf779329aac7a96200f579"; type="application/xop+xml"; start="<0.a2d526d5b9a7f9dba48a297330bf779329aac7a96200f579@apache.org>"; start-info="application/soap+xml"; action="http://localhost:8080/RequestEmailer/email?requestType=ANZSOAP&sendTo=daniel.szwed@nextgen.net"

--MIMEBoundary_d2d526d5b9a7f9dba48a297330bf779329aac7a96200f579
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
Content-Transfer-Encoding: binary
Content-ID: <0.a2d526d5b9a7f9dba48a297330bf779329aac7a96200f579@apache.org>

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header>
        <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">Application Centre</wsa:To>
        <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
            <wsa:Address>SAIG</wsa:Address>
        </wsa:From>
        <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://resources.nextgen.net/Reference/BUNDLE/wsdl/DocumentExchange</wsa:Action>
        <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">http://resources.nextgen.net/Storage/NextGen/BUNDLE/9b16574b-bc6f-4ace-88ab-5d12cc717dc7/e1ce7ca9-52cb-42f0-b9f0-784b72868713</wsa:MessageID>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsse:UsernameToken>
                <wsse:Username>DocumentExchangeUATNABSAIG</wsse:Username>
                <wsse:Password wsse:type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">*password goes here*</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <m:DocumentExchangeRequest xmlns:m="http://resources.nextgen.net/Reference/NextGen/WSDL/DocumentExchange/2016/03/29">
            <m:Documents m:bundleIdentifier="9b16574b-bc6f-4ace-88ab-5d12cc717dc7">
                <m:Document m:documentIdentifier="618e451f-d511-4f42-84ee-4520e6b2c7ef" m:documentPart="1" m:ofDocumentParts="1" m:batchPart="1" m:ofBatchParts="3">
                    <m:Data>
                        <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:35ca06c2-0b57-4cbf-84fa-09caaca4a0df"/>
                    </m:Data>
                    <dcds:descriptionSet xmlns:dcds="http://purl.org/dc/xmlns/2008/09/01/dc-ds-xml/">
                        <dcds:description xmlns:ns0="http://purl.org/dc/xmlns/2008/09/01/dc-ds-xml/">
                            <dcds:statement ns0:propertyURI="http://purl.org/dc/terms/creator">
                                <dcds:literalValueString>FunctionalTest</dcds:literalValueString>
                            </dcds:statement>
                        </dcds:description>
                    </dcds:descriptionSet>
                    <m:LoanFileIdentifiers>
                        <m:LoanFileIdentifier m:identifierType="ApplyOnlineID" m:identifierOwner="ApplyOnline">96544-NABBROKER</m:LoanFileIdentifier>
                    </m:LoanFileIdentifiers>
                </m:Document>
                <m:Document m:documentIdentifier="984c39cf-7004-426c-87d6-31a3362fff6e" m:documentPart="1" m:ofDocumentParts="2" m:batchPart="2" m:ofBatchParts="3">
                    <m:Data>
                        <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:038dbbbf-2328-430a-8081-35cfd4ac9de2"/>
                    </m:Data>
                    <dcds:descriptionSet xmlns:dcds="http://purl.org/dc/xmlns/2008/09/01/dc-ds-xml/">
                        <dcds:description xmlns:ns0="http://purl.org/dc/xmlns/2008/09/01/dc-ds-xml/">
                            <dcds:statement ns0:propertyURI="http://purl.org/dc/terms/creator">
                                <dcds:literalValueString>FunctionalTest</dcds:literalValueString>
                            </dcds:statement>
                        </dcds:description>
                    </dcds:descriptionSet>
                    <m:LoanFileIdentifiers>
                        <m:LoanFileIdentifier m:identifierType="ApplyOnlineID" m:identifierOwner="ApplyOnline">96544-NABBROKER</m:LoanFileIdentifier>
                    </m:LoanFileIdentifiers>
                </m:Document>
                <m:Document m:documentIdentifier="0fc3564b-4947-4522-8902-1706438bfbf1" m:documentPart="2" m:ofDocumentParts="2" m:batchPart="3" m:ofBatchParts="3">
                    <m:Data>
                        <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:f688eb04-2fc7-4037-9f1c-10682295b050"/>
                    </m:Data>
                    <dcds:descriptionSet xmlns:dcds="http://purl.org/dc/xmlns/2008/09/01/dc-ds-xml/">
                        <dcds:description xmlns:ns0="http://purl.org/dc/xmlns/2008/09/01/dc-ds-xml/">
                            <dcds:statement ns0:propertyURI="http://purl.org/dc/terms/creator">
                                <dcds:literalValueString>FunctionalTest</dcds:literalValueString>
                            </dcds:statement>
                        </dcds:description>
                    </dcds:descriptionSet>
                    <m:LoanFileIdentifiers>
                        <m:LoanFileIdentifier m:identifierType="ApplyOnlineID" m:identifierOwner="ApplyOnline">96544-NABBROKER</m:LoanFileIdentifier>
                    </m:LoanFileIdentifiers>
                </m:Document>
            </m:Documents>
        </m:DocumentExchangeRequest>
    </soapenv:Body>
</soapenv:Envelope>
--MIMEBoundary_d2d526d5b9a7f9dba48a297330bf779329aac7a96200f579
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <35ca06c2-0b57-4cbf-84fa-09caaca4a0df>

Document 1
--MIMEBoundary_d2d526d5b9a7f9dba48a297330bf779329aac7a96200f579
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <038dbbbf-2328-430a-8081-35cfd4ac9de2>

Document 2
--MIMEBoundary_d2d526d5b9a7f9dba48a297330bf779329aac7a96200f579
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <f688eb04-2fc7-4037-9f1c-10682295b050>

%PDF-1.4
<removed binary PDF content.>
%%EOF

--MIMEBoundary_d2d526d5b9a7f9dba48a297330bf779329aac7a96200f579--

Как мне написать веб-метод, который ожидает имя пользователя и пароль в параметре Header и rest в теле.

Я написал класс для сопоставления параметра

[Serializable]
    [DataContract (Namespace ="")]

    public class NextGetSupportDocHeader
    {

        [DataMember  ( IsRequired = true)] 
        public string DocumentID { get; set; }

        [DataMember()]
        public string DocumentCreated { get; set; }

        [DataMember(IsRequired = true)]
        public LoanFileIdentifiers LoanIdentifier { get; set; }
            }

    [Serializable]
    [DataContract(Namespace = "")]
    public  class LoanFileIdentifiers {
        [DataMember(IsRequired = true)]
        public string DocHeaderID { get; set; }

        [DataMember(IsRequired = true)]
        public string BrokerID { get; set; }

        [DataMember(IsRequired = true)]
        public string ApplyOnlineID { get; set; }
    }

Ниже приведен скелет webmethod

  [WebMethod(Description = "Send document on this")]

        public SupportingDocReply NextGenSupportingDoc(NextGetSupportDocHeader sDocMsg)
        {
            return null;
        }
  1. Как мне обновить класс для сопоставления сMIMEBoundary
  2. Как обновить класс, чтобы прочитать UsernameToken из заголовка

1 Ответ

0 голосов
/ 08 ноября 2019

Добавьте следующее в webconfig, чтобы служба была готова для MTOM и UserAuthentication

 <binding name="mtomBasic" closeTimeout="00:20:00" openTimeout="00:20:00"
          receiveTimeout="00:20:00" sendTimeout="00:20:00" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          textEncoding="utf-8" transferMode="Buffered" messageEncoding="Mtom">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" />
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
          </security>
        </binding>

Добавьте следующее в разделе Поведение для пользовательской аутентификации

<behavior name="NextGenServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceCredentials>

        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SupportingDocsFacade.ServiceAuthenticator,SupportingDocsFacade" />
      </serviceCredentials>

    </behavior>

Для проблемы 2 см. WSAAuthenticate

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...