2011-11-11 2 views
0

Soap1.1 서비스에 연결 중입니다. 이것은 업계 표준 인터페이스 정의 (유틸리티 공간에서 매우 일반적인 MultiSpeak라고 함)를 사용하는 기존 서비스입니다.WCF 클라이언트의 SOAP Envelope에 다른 NameSpace 포함

MultiSpeak 표준에는이 공급 업체가 필요로하는 CustomerID를 전달하는 조항이 없으므로 SoapEvenelope 약간. 내 문제는 적절한 XML을 방출하는 WCF를 납득시키는 방법을 생각할 수 없다는 것입니다.

나의 현재 봉투는 다음과 같습니다

여기
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Header> 
    <h:MultiSpeakMsgHeader UserID="****" Pwd="****" Company="****" 
     xmlns="http://www.multispeak.org/Version_3.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:h="http://www.multispeak.org/Version_3.0" /> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <GetAMRSupportedMeters xmlns="http://www.multispeak.org/Version_3.0" /> 
    </s:Body> 
</s:Envelope> 

내가이 일을 같이해야 할 작업은 다음과 같습니다

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Header> 
    <h:MultiSpeakMsgHeader UserID="****" Pwd="****" Company="****" 
     vendor:CustomerID="StringValue" 
     xmlns="http://www.multispeak.org/Version_3.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:h="http://www.multispeak.org/Version_3.0" 
     xmlns:vendor="http://www.MyVendor.com/Multispeak3"/> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <GetAMRSupportedMeters xmlns="http://www.multispeak.org/Version_3.0" /> 
    </s:Body> 

그래서 새로운 도입 네임 스페이스 (내 공급 업체의 사용자 정의 네임 스페이스)와 위에가있다 기존 "MultiSpeakMsgHeader"개체에 "CustomerID"라는 새 속성이 도입되었지만 해당 속성을 나타내는 XML의 특성이 다른 이름 공간에 있음

표준 멀티SPeak WSDL과 함께 사용하도록 제공 한 WSDL은이를 생성하지 않습니다.

"CustomerID"를 reference.cs의 MultiSpeakMsgHeader 객체에 문자열 속성으로 추가하기는 쉽지만 적절한 xmlns 장식으로 방출되지 않으므로 작동하지 않습니다 (예, 테스트했습니다. 그 ... 네임 스페이스 없음, 사랑 없음).

나는 손실에 처해있다. 나는 WSDL을 수정하고 작동하도록 재생성을 시도했지만 운이 없었다.

힌트와 나는 확실히 감사 할 것이다. 이미이 문제에 너무 많은 시간을 낭비했습니다.

감사합니다.

답변

1

자신 만의 비누 헤더를 만들 수 있습니다. 일부 샘플 코드는 다음과 같습니다.

using (OperationContextScope scope = new OperationContextScope(objService.InnerChannel)) 

     { 
      UsernameToken objUsernameToken = new UsernameToken() { Username = "rajesh", Password = "rajesh" }; 
      List<Type> obj = new List<Type>(); 
      obj.Add(typeof(UsernameToken)); 

      //XmlObjectSerializer ser = new DataContractSerializer(typeof(Security), "Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", obj); 

      XmlObjectSerializer ser = new CustomXmlSerializer(typeof(Security), "Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); 

      Security security = new Security(); 
      security.UsernameToken = objUsernameToken; 

      MessageHeader header = MessageHeader.CreateHeader("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", 
                   security, ser, false); 

      OperationContext.Current.OutgoingMessageHeaders.Add(header); 

      try 
      { 
       //Would get a exception but the response was successful. You can see that in fiddler. 
       //The cause for the exception is that the response has the security elements mustUnderstand set to 1 chagning that to 0 would resolve the problem. Need to find on how to do that 
       string response = objService.GetInformation(); 
      } 
      catch (Exception ex) 
      { 
       OperationContext.Current.IncomingMessageHeaders.RemoveAll("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); 
       //throw; 
      } 

     } 

희망 사항은 위의 코드를 요구 사항에 맞게 바꿀 수 있기를 바랍니다.