2 Replies Latest reply: Feb 8, 2011 2:42 AM by Floh-VerbaVoice RSS

    Invoke SOAP-Webservice by C#-Written Client

    Floh-VerbaVoice

      Hi, I'm working with Visual Studio 2010 C#. I'm trying to access a  SOAP-Endpoint of our server. Unfortunatelly I always get error because  of authentification.

       

      I added service reference there as described in following msdn doc: http://msdn.microsoft.com/en-us/library/bb386382.aspx

       

      Now I have a app.config file which contains settings for connecting SOAP-Endpoint. I feel somewhat is wrong there:

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
           <system.serviceModel>
               <bindings>
                   <basicHttpBinding>
                       <binding name="ReadEntriesSoapBinding" 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="TransportCredentialOnly">
                               <transport clientCredentialType="Basic" proxyCredentialType="None"
                                   realm="AXIS" />
                               <message clientCredentialType="UserName" algorithmSuite="Default" />
                           </security>
                       </binding>
                   </basicHttpBinding>
               </bindings>
               <client>
                   <endpoint address="http://****************:8080/soap/services/Calendar/Processes/ReadEntries"
                       binding="basicHttpBinding" bindingConfiguration="ReadEntriesSoapBinding"
                       contract="SoapServiceReference.Calendar_Processes_ReadEntries"
                       name="ReadEntries" />
               </client>
           </system.serviceModel>
      </configuration>

       

      And here is C#-Code:

      SoapServiceReference.Calendar_Processes_ReadEntriesClient  client = new  SoapServiceReference.Calendar_Processes_ReadEntriesClient();
      SoapServiceReference.XML xml;
      SoapServiceReference.DATE end = new SoapServiceReference.DATE();
      end.date = DateTime..Today.AddYears(100);
      String impairedPersonUID = "**************";
      SoapServiceReference.DATE start = new SoapServiceReference.DATE();
      start.date = DateTime.Today.AddYears(-1);

       

      // Dunno which of them is needed?

      client.ClientCredentials.Windows.ClientCredential.UserName = "*********";
      client.ClientCredentials.Windows.ClientCredential.Password = "12345678";
      client.ClientCredentials.UserName.UserName = "*********";
      client.ClientCredentials.UserName.UserName = "12345678";

       

      xml = client.invoke(end, impairedPersonUID, start);

       

       

      In the last C#-line (client.invoke(...);) I always get error message. Now I get such one:

      "Die  HTTP-Anforderung ist beim Clientauthentifizierungsschema "Basic" nicht  autorisiert. Vom Server wurde der Authentifizierungsheader "Basic  realm="AXIS"" empfangen."

       

      Translated to English:

      "The HTTP request is unauthorized with client authentication scheme  'Anonymous'. The authentication header received from the server was  'Basic realm=\"AXIS\"'."

       

      In app.config before I tried some modifications the security-part was:

                          <security mode="None">
                               <transport clientCredentialType="None" proxyCredentialType="None"
                                   realm="" />
                               <message clientCredentialType="UserName" algorithmSuite="Default" />
                           </security>

       

       

      So... I need your help, what did I wrong? Do you need some informations, then let me know please.

      cu Floh

        • 1. Re: Invoke SOAP-Webservice by C#-Written Client
          Hodmi techies

          I'm the first to admit that I'm not a .net expert, but I've worked on a few small proofs that use c# and LiveCycle.

           

          There are a couple of things that I noticed about your code that are different from the way I've done things in the past:

          • I've always used a Web Reference as opposed to the Service Reference. 
          • Depending on how I've made the call, I've had to specify the message type (blob, MIME, MTOM) in the reference code.  This requires adding the message type identifier to the web service target url (see http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000537.html#185 7169)
          • The security settings for the user name and password are set with the web reference object using the .Credentials
          • The user name and password are for the LiveCycle server and therefor needs to be a valid account in the LiveCycle User Manager system.  administrator/password will work for the default system unless your administrator has changed the account (which he should do in production)
          • You'll need to pull the result object out of the returned message.  This will change somewhat depending on what message type you use.

           

           

          I'm not sure which version of LiveCycle you are using, but the API Quickstarts have some good examples for .Net/C# calls.  Have a look at:

          http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000005.html

          • 2. Re: Invoke SOAP-Webservice by C#-Written Client
            Floh-VerbaVoice Community Member

            Hi Hodmi,

            sorry for not replying a long time ago. I was busy. Thank you for your help.

             

            I found out what I did wrong:

            function(){return A.apply(null,[this].concat($A(arguments)))}

            client.ClientCredentials.UserName.UserName = "*********";
            client.ClientCredentials.UserName.UserName = "12345678";

             

            I accidentally wrote UserName twice, the second line should be Password:

            function(){return A.apply(null,[this].concat($A(arguments)))}

            client.ClientCredentials.UserName.UserName = "*********";
            client.ClientCredentials.UserName.Password = "12345678";

             

            Now its fine and working.

             

            cu Floh