服务器端映射 SOAP MTOM 格式(MIME 边界)



我正在尝试找到一种方法来编写可以处理肥皂MTOM格式的Web方法。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--

如何编写网络 方法,该方法需要标头中的用户名和密码以及正文中的 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(Description = "Send document on this")]

public SupportingDocReply NextGenSupportingDoc(NextGetSupportDocHeader sDocMsg)
{
return null;
}
  1. 如何更新类以映射到 MIMEBoundary
  2. 如何更新类以从标头读取用户名令牌

在 webconfig 中添加以下内容,以使服务为 MTOM 和用户身份验证做好准备

<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

最新更新