2011-07-28 30 views
1

我使用的是一個衆所周知的供應商API用WSDL link1link2(點擊wait to download):帶有.NET問題的Java WebService。結果與scvutil不同/包,而不是

上面提到的文檔要我創建一個認證請求報文是這樣的:

<soapenv:Envelope xmlns:soapenv=‖http://schemas.xmlsoap.org/soap/envelope/‖ 
xmlns:web=‖http://UltraWebServiceLocation/‖> 
<soapenv:Header> 
<wsse:Security soapenv:mustUnderstand=‖1‖ xmlns:wsse=‖http://docs.oasisopen. 
org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd‖> 
<wsse:UsernameToken wsu:Id=‖UsernameToken-16318950‖ xmlns:wsu=‖http://docs.oasisopen. 
org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd‖> 
<wsse:Username>bwooster</wsse:Username> 
<wsse:Password Type=‖http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername- 
token-profile-1.0#PasswordText‖>**********</wsse:Password> 
<wsse:Nonce>QTvkiqEFK7uJuOssMndagA==</wsse:Nonce> 
<wsu:Created>2009-04-14T21:20:57.108Z</wsu:Created> 
</wsse:UsernameToken> 
</wsse:Security> 
</soapenv:Header> 

我的客戶端綁定看起來像這樣;並使用服務引用而不是Web引用。

 UltraDNS.UltraDNS1Client client = new UltraDNS.UltraDNS1Client(); 
     client.ClientCredentials.UserName.UserName = "user"; 
     client.ClientCredentials.UserName.Password = "pass"; 

     var results = client.getResourceRecordsOfZone("domain.com",1); 
     // Throws InvalidOperationException: There was an error reflecting 'UltraWSException'. 
     // Detail: 
     //{"Namespace='http://webservice.api.ultra.neustar.com/v01/' is not supported with rpc\\literal SOAP. The wrapper element has to be unqualified."} 

web配置看起來像這樣

<system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="UltraDNS1Binding" closeTimeout="00:01:00" openTimeout="00:01:00" 
        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
        useDefaultWebProxy="true"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <security mode="None"> 
         <transport clientCredentialType="None" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="UserName" algorithmSuite="Default" /> 
        </security> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://ultra-api.ultradns.com:80/UltraDNS_WS/v01" 
       binding="basicHttpBinding" bindingConfiguration="UltraDNS1Binding" 
       contract="UltraDNSService.UltraDNS1" name="UltraWebServiceV01Port" /> 
     </client> 
    </system.serviceModel> 

當我使用SvcUtil工具與/wrap參數我收到以下錯誤生成代理類:

{"The top XML element 'result' from namespace '' references distinct types System.String and ZoneInfoData[]. Use XML attributes to specify another XML name or namespace for the element or types."} 

回答

0

你似乎有使用「添加Web引用」。請改爲使用「添加服務參考」。

然後參見Programming WCF Security


該服務正在向您發送某種錯誤(UltraWSException)。 WCF在反序列化時遇到了麻煩,但是如果你打開消息跟蹤,你可能會看到錯誤是什麼,並修復它。

+0

我嘗試過,但遇到SOAP/Literal被啓用的錯誤。我改變了生成引用中所有類和方法的設置,但沒有運氣。 – LamonteCristo

+0

如果您需要實際幫助,請發佈實際錯誤。 –

+0

感謝您的幫助;我喝咖啡休息一下以獲得全新的視角......更新了問題。 – LamonteCristo