Visual Studio 2008에서 비누 요청에 비누 헤더 추가
-
06-07-2019 - |
문제
타사 웹 서비스를 사용하려고 노력하고 있습니다 (웹 서비스 코드에 액세스 할 수 없습니다). Visual Studio 2008에서 나는 새로운 웹 사이트 프로젝트 (ASP 및 C#)를 만들고 웹 참조 (웹 서비스가 아님! WCF 서비스가 아니라고 생각합니까?)를 추가했습니다.
문제는 웹 서비스의 문서화에서 각 비누 요청이 다음 봉투와 헤더와 함께 전송되어야한다는 것을 알고 있습니다. 비누 요청에 이것을 추가하는 방법을 알려주시겠습니까? 웹 서비스 소스 또는 프록시를 수정 해야하는 모든 솔루션은 Visual Studio 2008의 클라이언트의 웹 서비스 소스와 웹 서비스 프록시에 액세스 할 수 없기 때문에 그렇게 할 수 없습니다. 임시 파일!
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" soap:mustUnderstand="1">
<wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>gimme.data@stats.com</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Ima5tatto</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body xmlns:ns2="http://neighbourhood.statistics.gov.uk/nde/v1-0/discoverystructs">
<ns2:AreaAtLevelElement>
<AreaIdWithLevelType>
<AreaId>276704</AreaId>
<LevelTypeId>12</LevelTypeId>
</AreaIdWithLevelType>
</ns2:AreaAtLevelElement>
</soap:Body>
</soap:Envelope>
다른 팁
나는이 같은 문제로 어려움을 겪고 있으며 지금까지 메시지 검사관 비누 헤더에 도달 할 수 있으려면 WSSE를 얻는 방법은 확실하지 않지만 수동으로 수행하지 않고도 보안 물건을 얻습니다. WS-Security Schema (및 SAML Schemas)를 사용하여 WSSE : 보안 재료 ...
내 메시지 검사관 코드는 아래에 있습니다.이를 해결하면이 스레드에 게시하겠습니다.
다음은 고객에게 동작을 추가하는 곳입니다.
client.Endpoint.Behaviors.Add(new CustomBehavior());
msgOutput = client.ProvideAndRegisterDocumentSetXDR(msgInput);
그리고 여기 메시지 검사관과 맞춤 행동이 있습니다.
public class CustomMessageInspector : System.ServiceModel.Dispatcher.IClientMessageInspector
{
public void AfterReceiveReply(ref WCF.Message reply, object correclationState)
{
}
public Object BeforeSendRequest(ref WCF.Message request, IClientChannel channel)
{
MessageHeaders headers = new MessageHeaders(MessageVersion.Soap11WSAddressing10);
MessageHeader header = MessageHeader.CreateHeader("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "");
request.Headers.Add(header);
return null;
}
}
public class CustomBehavior : System.ServiceModel.Description.IEndpointBehavior
{
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRunTime)
{
CustomMessageInspector inspector = new CustomMessageInspector();
clientRunTime.MessageInspectors.Add(inspector);
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
제휴하지 않습니다 StackOverflow