在Delphi中使用webservice

时间:2018-04-22 19:31:58

标签: delphi

我可以使用wsdl https://uslugaterytws1test.stat.gov.pl/terytws1.svc

访问webservice https://uslugaterytws1test.stat.gov.pl/wsdl/terytws1.wsdl

用户名:TestPubliczny和密码:1234abcd

我尝试导入wsdl然后放置2个组件:

  object htpr1: THTTPRIO
    WSDLLocation = 'https://uslugaterytws1test.stat.gov.pl/wsdl/terytws1.wsdl'
    Service = 'TerytWs1'
    Port = 'custom'
    HTTPWebNode = htprqrsp1
    Converter.Options = [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soCacheMimeResponse, soUTF8EncodeXML]
    Left = 264
    Top = 325
  end
  object htprqrsp1: THTTPReqResp
    UserName = 'TestPubliczny'
    Password = '1234abcd'
    UseUTF8InHeader = True
    InvokeOptions = [soIgnoreInvalidCerts, soAutoCheckAccessPointViaUDDI]
    WebNodeOptions = []
    UDDIOperator = '0'
    Left = 296
    Top = 376
  end

在.pas文件中:

var
  ten: terytws1.ITerytWs1;

begin
ten := (htpr1 as terytws1.ITerytWs1);

ShowMessage(BoolToStr(ten.CzyZalogowany));
end;

但是我得到请求超时,同时消耗使用C#中的应用程序正常工作。

在webservice sugest的C#提供程序中使用此代码:

try
         {
           var proxy = new ChannelFactory<ServiceReferenceWCF.ITerytWs1>("custom");

proxy.Credentials.UserName.UserName = TestPubliczny; 

proxy.Credentials.UserName.Password = 1234abcd; 

var result = proxy.CreateChannel(); 

var test = result.CzyZalogowany();                 
         }
         catch (Exception ex) { }  

<client>
   <endpoint address="https://uslugaterytws1test.stat.gov.pl/terytws1.svc"
                binding="customBinding" bindingConfiguration="custom"
contract="ServiceReference1.ITerytWs1" name="custom" />
</client> 

<bindings>
     <customBinding>
       <binding name="custom">
           <security defaultAlgorithmSuite="Default"  

authenticationMode="UserNameOverTransport" 
       requireDerivedKeys="true" includeTimestamp="true"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruar
y2005WSSecurityPolicy11BasicSecurityProfile10">
             <localClientSettings detectReplays="false" />
             <localServiceSettings detectReplays="false" />
           </security>
           <textMessageEncoding messageVersion="Soap11WSAddressing10" />
           <httpsTransport  maxReceivedMessageSize="2147483647"  

maxBufferPoolSize="2147483647"/> 
                </binding>
     </customBinding>
  </bindings> 

正如我之前从C#写的那样,我没有问题地服务

0 个答案:

没有答案
相关问题