Aklımda Kalası Kelimeler

* давайте работать вместе
* Zarf ve Mazruf, Zerafet(xHoyratlık) ile aynı kökten(za-ra-fe) gelir
* Bedesten
* Suç subuta ermiştir - Suç sabit olmuştur
WCF etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
WCF etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

1 Nisan 2015 Çarşamba

Fiddler ile WCF servisini çağırmak

WSDL'ı parça parça aşağıdan okuyalım.

Çağıracağımız fonksiyonda iki farklı tipte iki parametre var QueryInboxInvoiceStatus(InvoiceLogin _invoiceLogin, string[] _invoiceIds)
İşte fonksiyonumuzun WSDL'daki ifadesi:
<xs:element name="QueryInboxInvoiceStatus">
 <xs:complexType>
  <xs:sequence>
   <xs:element xmlns:q29="http://schemas.datacontract.org/2004/07/FMC.Turkiye.Lib.EInvoice" minOccurs="0" name="_invoiceLogin" nillable="true" type="q29:InvoiceLogin"/>
   <xs:element xmlns:q30="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="_invoiceIds" nillable="true" type="q30:ArrayOfstring"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

_invoiceIds parametremiz string tipinde bir dizi. Bunda dikkat edeceğimiz husus xml namespace bilgisinin doğru yazılması. Karmaşık bir tip(complex type) olmadığı için detayı yok ama InvoiceLogin için var:
<xs:complexType name="InvoiceLogin">
 <xs:sequence>
  <xs:element minOccurs="0" name="Password" nillable="true" type="xs:string"/>
  <xs:element minOccurs="0" name="UserName" nillable="true" type="xs:string"/>
 </xs:sequence>
</xs:complexType>
2 tane string tipinde özelliği olan bir sınıf. Şuna benziyor olsa gerek:
class InvoiceLogin
{
  public string UserName;
  public string Password;
}
Şimdi xml namespace bilgileri fiddler ile talebimizi yaparken nasıl yer alıyor:


O halde bu web servis metodunu çağırdığımak için aşağıdaki http gövdesini kullanacağız:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <QueryInboxInvoiceStatus xmlns="http://gib.fresenius.com.tr/FEFatura">
   <_invoiceLogin xmlns:a="http://schemas.datacontract.org/2004/07/FMC.Turkiye.Lib.EInvoice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <a:Password>şifremiz</a:Password>
    <a:UserName>kullanıcıAdı</a:UserName>
   </_invoiceLogin>
   <_invoiceIds  xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <b:string>353d5faf-f227-4600-8efe-3fb5ab0f1f48</b:string>
   </_invoiceIds>
  </QueryInboxInvoiceStatus>
 </s:Body>
</s:Envelope>

Bu da fiddler üstünden çağırmak için kullanacağımız http talebi ve cevabı:
POST http://localhost:53644/FEInvoice.svc HTTP/1.1
Content-Type: text/xml; charset=utf-8
VsDebuggerCausalityData: uIDPoxWgzmMUISZHhT9DgBmdvzAAAAAAA/+at96K6Uq35zPRjKxBIsVGn2pZnrlOgakzi+yKWdsACQAA
SOAPAction: "http://gib.fresenius.com.tr/FEFatura/IFEInvoice/QueryInboxInvoiceStatus" 
Host: localhost:53644
Content-Length: 677
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <QueryInboxInvoiceStatus xmlns="http://gib.fresenius.com.tr/FEFatura">
   <_invoiceLogin xmlns:a="http://schemas.datacontract.org/2004/07/FMC.Turkiye.Lib.EInvoice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <a:Password>şifremizBudur</a:Password>
    <a:UserName>kullaniciAdimizBuOlsun</a:UserName>
   </_invoiceLogin>
   <_invoiceIds  xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <b:string>353d5faf-f227-4600-8efe-3fb5ab0f1f48</b:string>
   </_invoiceIds>
  </QueryInboxInvoiceStatus>
 </s:Body>
</s:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Vary: Accept-Encoding
Server: Microsoft-IIS/8.0
X-SourceFiles: =?UTF-8?B?QzpcUHJvamVsZXJcRk1DLlR1cmtpeWUuV2NmLkVGYXR1cmFcdHJ1bmtcRkVJbnZvaWNlLnN2Yw==?=
X-Powered-By: ASP.NET
Date: Wed, 01 Apr 2015 10:07:45 GMT
Content-Length: 929

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
  <QueryInboxInvoiceStatusResponse xmlns="http://gib.fresenius.com.tr/FEFatura">
   <QueryInboxInvoiceStatusResult xmlns:a="http://schemas.datacontract.org/2004/07/FMC.Turkiye.Lib.EInvoice" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <a:Nesne i:nil="true"/>
    <a:hasError>false</a:hasError>
    <a:invoiceResult i:nil="true"/>
    <a:islem>QueryInboxInvoiceStatus Metodu</a:islem>
    <a:istisna i:nil="true"/>
    <a:lstWsResult>
     <a:WSResult>
      <a:Nesne i:nil="true"/>
      <a:hasError>false</a:hasError>
      <a:invoiceResult i:nil="true"/>
      <a:islem>QueryInboxInvoiceStatus Metodu</a:islem>
      <a:istisna i:nil="true"/>
      <a:lstWsResult/>
      <a:sonuc i:nil="true"/>
      <a:succeedTransaction>true</a:succeedTransaction>
     </a:WSResult>
    </a:lstWsResult>
    <a:sonuc i:nil="true"/>
    <a:succeedTransaction>false</a:succeedTransaction>
   </QueryInboxInvoiceStatusResult>
  </QueryInboxInvoiceStatusResponse>
 </s:Body>
</s:Envelope>

Uyumsoft WCF Servisine Talep

Şimdi bu talebi uyumsoft'un e-fatura servislerine nasıl yapabiliriz bakalım ve bilgimizi ikinci bir örnek ile ilerletelimki anlayışımız artsın.
Önce metodumuzu wsdl içinde bulalım:
soapAction servisi çağırırken hangi metodu çağıracağı bilgisini içeriyor.

input ile metoda verilecek parametreleri, output ile çıktı olarak üreteceği sonucu görüyorsunuz.

Peki parametrenin veri tipi ne?
ArrayOfString tipi olacak.

Şimdi talebimizi yapalım:
POST https://efatura.uyumsoft.com.tr/Services/Integration HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IIntegration/QueryInboxInvoiceStatus"
Host: efatura.uyumsoft.com.tr
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Content-Length: 937


 
  
   
    kullaniciAdimiz
    şifremiz
   
  
 
 
  
   
    353d5faf-f227-4600-8efe-3fb5ab0f1f48
   
  
 

Ve cevabımız:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=giq1anjro5kiajmwxzar1t11; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 01 Apr 2015 11:26:03 GMT
Content-Length: 845


 
  
   
    2015-04-01T11:26:04.353Z
    2015-04-01T11:31:04.353Z
   
  
 
 
  
   
    
   
  
 

Kolay gelsin....

20 Kasım 2013 Çarşamba

WCF'te tanımlı interface(arayüz) istemci(client) de nasıl görünüyor

Temel olarak çalışma şeklim her durumu ince detaylarına varıncaya kadar irdelemektir. Sonuçta en basit haliyle sunucu tarafındaki ServiceContract olarak tanımlı Interface'in istemci tarafında nasıl hayat bulduğunu görmek istedim.

Interface aynı şekliyle istemciye gelmiş ek olarak System.Threading.Tasks.Task<t> metotAdiAsync(parametreleri) diye asenkron metodu eklenmiş.
İşte ekranı görüntüsü:
Bu adres fena anlatmamış: http://www.yazgelistir.com

Yukarıda arayüzün istemci tarafındaki şeklini gördük. Aşağıda ise bu arayüzü System.ServiceModel.ClientBase<Arayuz> ile istemci oluşturmak için nasıl miras alındığını göreceğiz.
Sınıfımız System.ServiceModel.ClientBase sınıfından türetiltiği için Channel özelliği ile kanalın üstünden metot çağrılarını yapabiliyoruz.

11 Kasım 2013 Pazartesi

XML tiplerinden NormalizedString ile String farkı

normalizedString

string veri elemanının tanımı:
   <xs:element name="customer" type="xs:string"/>
Veri taşırken:
   <customer>John Smith</customer>
ya da tab tuşu ile şu şekilde değeri olabilir
   <customer>       John Smith     </customer>
ve string kullandığımız için XML işlemcisi elemanın değerini değiştirmeyecektir ve 
  * satır besleme (#xA) 
  * satırbaşı karakterlerini (#xD) 
  * sekme (#x9) karakterleri aynı kalacaktır...

Ama NormalizedString veri elemanını kullanırsak (#xA),(#xD),(#x9) karakterleri, boşluk karakterine(#x20) dönüştürülür...
normalizedString veri elemanının tanımı:
   <xs:element name="customer" type="xs:normalizedString"/>
Veri taşırken:
   <customer>John Smith</customer>
ya da tab tuşu(#x9) ile girilmiş değerler boşluk karakterine(#x20) ye dönüştürülüyor
   <customer>       John Smith     </customer>
Ref:
www.w3schools.com
http://support.microsoft.com


24 Eylül 2013 Salı

Types of WCF Binding


WCF provides nine built-in bindings:
  • BasicHttpBinding: Basic web service communication. Exposes WCF services as legacy ASMX web services. Used for interoperability. No security by default.
  • WSHttpBinding: Web services with WS-* support. Supports transactions and reliable messaging.
  • WSDualHttpBinding: Web services with duplex contract and transaction support.
  • WSFederationHttpBinding: Web services with federated security. Supports transactions.
  • MsmqIntegrationBinding: Communication directly with MSMQ applications. Supports transactions.
  • NetMsmqBinding: Communication between WCF applications by using queuing. Supports transactions.
  • NetNamedPipeBinding: Communication between WCF applications on same computer. Supports duplex contracts and transactions.
  • NetPeerTcpBinding: Communication between computers across peer-to-peer services. Supports duplex contracts.
  • NetTcpBinding: Communication between WCF applications across computers. Supports duplex contracts and transactions.
  • Although most bindings will work on scenarios they are not designed for, it's a good practice to choose the right binding for a given a situation. You need to identify your potential use-cases and apply a Binding Decision best practices.
http://wcftutorial.net/WCF-Types-of-Binding.aspx

BasicHttpBinding

It is suitable for communicating with ASP.NET Web services (ASMX)-based services that comfort with WS-Basic Profile conformant Web services.
This binding uses HTTP as the transport and text/XML as the default message encoding.
Security is disabled by default
This binding does not support WS-* functionalities like WS- Addressing, WS-Security, WS-ReliableMessaging
It is fairly weak on interoperability.

WSHttpBinding

Defines a secure, reliable, interoperable binding suitable for non-duplex service contracts.
It offers lot more functionality in the area of interoperability.
It supports WS-* functionality and distributed transactions with reliable and secure sessions using SOAP security.
It uses HTTP and HTTPS transport for communication.
Reliable sessions are disabled by default.

WSDualHttpBinding

This binding is same as that of WSHttpBinding, except it supports duplex service. Duplex service is a service which uses duplex message pattern, which allows service to communicate with client via callback.

In WSDualHttpBinding reliable sessions are enabled by default. It also supports communication via SOAP intermediaries.

WSFederationHttpBinding

This binding support federated security. It helps implementing federation which is the ability to flow and share identities across multiple enterprises or trust domains for authentication and authorization. It supports WS-Federation protocol.

NetTcpBinding

This binding provides secure and reliable binding environment for .Net to .Net cross machine communication. By default it creates communication stack using WS-ReliableMessaging protocol for reliability, TCP for message delivery and windows security for message and authentication at run time. It uses TCP protocol and provides support for security, transaction and reliability.

NetNamedPipeBinding

This binding provides secure and reliable binding environment for on-machine cross process communication. It uses NamedPipe protocol and provides full support for SOAP security, transaction and reliability. By default it creates communication stack with WS-ReliableMessaging for reliability, transport security for transfer security, named pipes for message delivery and binary encoding.

NetMsmqBinding

This binding provides secure and reliable queued communication for cross-machine environment.
Queuing is provided by using MSMQ as transport.
It enables for disconnected operations, failure isolation and load leveling

NetPeerTcpBinding

This binding provides secure binding for peer-to-peer environment and network applications.
It uses TCP protocol for communication
It provides full support for SOAP security, transaction and reliability.

WCF Konfigurasyonu


SECURITY

  1. sslStreamSecurity
  2. windowsStreamSecurity

TRANSPORT

  1. tcpTransport
  2. udpTransport
  3. httpTransport
  4. httpsTransport
  5. msmqTransport
  6. namedPipeTransport
  7. peerTransport

ENCODING

  1. webMessageEncoding :
  2. binaryMessageEncoding : 0 1 0 1 1 0 ( 2)
    *** binaryMessageEncoding 
      POST https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWS HTTP/1.1
      Content-Type: application/soap+msbin1
      Host: medula.sgk.gov.tr
      Content-Length: 509
      Expect: 100-continue
      Accept-Encoding: gzip, deflate
      Connection: Keep-Alive
    
      V 
       s 
       a 
       ufV D
       ��� basvuruTakipOkuD � �E��J�K�~W�BHd�D,D*�  D  ���>https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWSRh ��
       oHXj  � _0Xl� 2017-05-03T13:58:19.394ZXn� 2017-05-03T14:03:19.394Z R�   �+uuid-3ec0ddd2-177f-4a73-8278-92f1d69cc5b7-1R� � 12525018R� �
      Toprak.2018   V   xsi)http://www.w3.org/2001/XMLSchema-instance  xsd http://www.w3.org/2001/XMLSchema@ basvuruTakipOku "http://servisler.ws.gss.sgk.gov.tr@ basvuruTakipOkuDVO �@ hastaBasvuruNo� B_1W92A2V@ saglikTesisKodu� 12525018    
    
    
  3. byteStreamMessageEncoding : 49 F6 14 1A (16)
  4. mtomMessageEncoding :
    *** mtomMessageEncoding:
    POST https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWS HTTP/1.1
    MIME-Version: 1.0
    Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:50382c25-f838-4e0f-86f6-4edcc321ef33+id=1";start-info="application/soap+xml"
    Host: medula.sgk.gov.tr
    Content-Length: 1560
    Expect: 100-continue
    Accept-Encoding: gzip, deflate
    Connection: Keep-Alive
    
    
    --uuid:50382c25-f838-4e0f-86f6-4edcc321ef33+id=1
    Content-ID: <http://tempuri.org/0>
    Content-Transfer-Encoding: 8bit
    Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
    
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action s:mustUnderstand="1">basvuruTakipOku</a:Action><a:MessageID>urn:uuid:4989f7dc-c94e-49f6-87ed-67240114441f</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWS</a:To><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2017-05-03T13:50:58.115Z</u:Created><u:Expires>2017-05-03T13:55:58.115Z</u:Expires></u:Timestamp><o:UsernameToken u:Id="uuid-6c984263-37f2-4305-9a75-3a2a5628a210-1"><o:Username>12525018</o:Username><o:Password>Toprak.2018</o:Password></o:UsernameToken></o:Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><basvuruTakipOku xmlns="http://servisler.ws.gss.sgk.gov.tr"><basvuruTakipOkuDVO xmlns=""><hastaBasvuruNo>B_1W92A2V</hastaBasvuruNo><saglikTesisKodu>12525018</saglikTesisKodu></basvuruTakipOkuDVO></basvuruTakipOku></s:Body></s:Envelope>
    --uuid:50382c25-f838-4e0f-86f6-4edcc321ef33+id=1--
    
  5. textMessageEncoding : lkasjdhfjkasdfjh asdfj
    *** textMessageEncoding 
      POST https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWS HTTP/1.1
      Content-Type: application/soap+xml; charset=utf-8
      Host: medula.sgk.gov.tr
      Content-Length: 1306
      Expect: 100-continue
      Accept-Encoding: gzip, deflate
      Connection: Keep-Alive
    
      <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><a:Action s:mustUnderstand="1">basvuruTakipOku</a:Action><a:MessageID>urn:uuid:3be0b46c-3047-485d-b923-b50c4a7d813d</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWS</a:To><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2017-05-03T13:55:47.230Z</u:Created><u:Expires>2017-05-03T14:00:47.230Z</u:Expires></u:Timestamp><o:UsernameToken u:Id="uuid-b98f41cf-0919-415b-b655-6fe8a470136e-1"><o:Username>12525018</o:Username><o:Password>Toprak.2018</o:Password></o:UsernameToken></o:Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><basvuruTakipOku xmlns="http://servisler.ws.gss.sgk.gov.tr"><basvuruTakipOkuDVO xmlns=""><hastaBasvuruNo>B_1W92A2V</hastaBasvuruNo><saglikTesisKodu>12525018</saglikTesisKodu></basvuruTakipOkuDVO></basvuruTakipOku></s:Body></s:Envelope>
    

Security


E-Nabız SOAP Zarfı
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
 <s:Header>
  <a:Action s:mustUnderstand="1">basvuruTakipOku</a:Action>
  <a:MessageID>urn:uuid:47fdd9ad-5297-4398-a2ce-ccaa33634a52</a:MessageID>
  <a:ReplyTo>
   <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
  </a:ReplyTo>
  <a:To s:mustUnderstand="1">https://medula.sgk.gov.tr/medula/hastane/hastaKabulIslemleriWS</a:To>
  <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
   <o:UsernameToken u:Id="uuid-dfee9603-6065-44fb-8190-6f93ccfdad90-1">
    <o:Username>kullaniciAdi1234</o:Username>
    <o:Password>sifre1234</o:Password>
   </o:UsernameToken>
  </o:Security>
 </s:Header>
 <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <basvuruTakipOku xmlns="http://servisler.ws.gss.sgk.gov.tr">
   <basvuruTakipOkuDVO xmlns="">
    <hastaBasvuruNo>B_1W9T8KT</hastaBasvuruNo>
    <saglikTesisKodu>123TesisKodu</saglikTesisKodu>
   </basvuruTakipOkuDVO>
  </basvuruTakipOku>
 </s:Body>
</s:Envelope>

5 Nisan 2013 Cuma

WCF incelemesi

WCF çağrısı:


Behaviour eklemek:



public class CustomBehaviour : IEndpointBehavior
{
    public void Validate(ServiceEndpoint endpoint)
    {


public class CustomBehaviour : IEndpointBehavior
{
    public void Validate(ServiceEndpoint endpoint)
    {
    }
    public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
    {

bindingParameters:


endpoint:

public class CustomBehaviour : IEndpointBehavior
{
    public void Validate(ServiceEndpoint endpoint)
    {
    }
    public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
    {
    }
    public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
    {
        CustomBehaviour custom = ((CustomBehaviour)(endpoint.Behaviors[typeof(CustomBehaviour)]));
        MessageInspector mi = new MessageInspector()
            {
                M_Key = custom.M_Key,
                M_Value = custom.M_Value
            };
            
        clientRuntime.MessageInspectors.Add(mi);
    }
clientRuntime: