none
Call Java service in Jax-WS binding from C#.net RRS feed

  • Question

  • I need to call https://www.sunat.gob.pe/ol-ti-itcpgem-beta/billService?wsdl service created in JAX-WS binding from C#.

    I am getting below exception always.

    An unhandled exception of type 'System.ServiceModel.CommunicationException' occurred in mscorlib.dll

    Additional information: An error occurred while receiving the HTTP response to https://www.sunat.gob.pe/ol-ti-itcpgem-beta/billService. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

    Below is my configuration:

        

    <system.serviceModel>    

        <bindings>
          <wsHttpBinding>
            <binding name="MYwsHttpBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
                     bypassProxyOnLocal="false"
                transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
              <readerQuotas  maxDepth = "32"  maxStringContentLength = "8192"  maxArrayLength = "16384"
          maxBytesPerRead = "4096"  maxNameTableCharCount = "16384"  />
              <security mode="Transport">
                <transport  clientCredentialType = "None"  proxyCredentialType = "None"  realm = ""  />
                <message  clientCredentialType = "UserName"  algorithmSuite = "Default" />
              </security>
            </binding>
          </wsHttpBinding>
          <basicHttpBinding>
            <binding name="BillServicePortBinding" 
                     closeTimeout = "10:00:00"
         openTimeout = "10:00:00"  receiveTimeout = "10:00:00"  sendTimeout = "24:00: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="Transport">
                <transport  clientCredentialType = "None"  proxyCredentialType = "None"  realm = ""  />
                <message  clientCredentialType = "UserName"  algorithmSuite = "Default" />
              </security>
            </binding>
            <!--<binding  name = "secured" >
                    <security  mode = "TransportWithMessageCredential" >
                      <message  clientCredentialType = "UserName"  />
                    </security >
                  </binding >-->
          </basicHttpBinding>
        </bindings>

        <client>
          <!--address="https://www.sunat.gob.pe/ol-ti-itcpgem/billService"-->
          <!--""-->
          <endpoint address="https://www.sunat.gob.pe:443/ol-ti-itcpgem-beta/billService"
          binding="wsHttpBinding" bindingConfiguration="MYwsHttpBinding"
          contract="SunatService.billService" name="BillServicePort">
          <headers >
              <wsse:Security  xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" >
                <wsse:UsernameToken  >
                  <wsse:Username >20100066603MODDATOS</wsse:Username >
                  <!--Type = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'-->
                  <wsse:Password>moddatos</wsse:Password >
                </wsse:UsernameToken >
              </wsse:Security >
            </headers >
          </endpoint>
        </client>
      </system.serviceModel>

    Please help.


    Ram Swami

    Monday, April 6, 2015 10:35 AM

Answers

All replies

  • Hi Ram Swami,

    When I try to add services reference by using this: https://www.sunat.gob.pe/ol-ti-itcpgem-beta/billService?wsdl, it generates a baiscHttpBinding in my client config file, so could you please try to use the baiscHttpBinding in your client config file for instead to see if it works? The following article is about accessing Java service(Jax-WS) from C#.net, please try to check it:
    http://gayandenzil.blogspot.jp/2012/07/write-web-service-using-jax-ws-and.html .
    Besides, this forum is used to discuss the questions about the WCF Web Service, for the questions about the others web services, please try to post in this forum: http://forums.asp.net/28.aspx/1?WCF+ASMX+and+other+Web+Services .
    Thanks for your understanding.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Tuesday, April 7, 2015 6:12 AM
    Moderator
  • yes why not
    Tuesday, April 7, 2015 5:39 PM
  • Lograste conectarte?? que error te sale?

    Tuesday, April 14, 2015 3:31 PM
  • you solved your error??...
    you know the solution?
    Wednesday, April 15, 2015 9:02 PM
  • Hi Ram Swami,

    I will mark my reply as answer, if you feel it useless, please unmark it in your free time.
    Thanks for your understanding.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 20, 2015 10:30 AM
    Moderator
  • Hola, pudiste conectarte al servicio?
    Monday, May 4, 2015 4:17 PM
  • Estimados tengo el bendito error en lo que es la homologacion por favor necesito de su ayuda

    Espero que me puedan ayudar 

    El Error :

    La respuesta de Error es :  - 

    En el detalle : 

                        Code Name : 0103

    Codigo :

                System.Net.ServicePointManager.UseNagleAlgorithm = true;
                System.Net.ServicePointManager.Expect100Continue = false;
                System.Net.ServicePointManager.CheckCertificateRevocationList = true;

                BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;

                string sURL = "https://www.sunat.gob.pe:443/ol-ti-itcpgem-sqa/billService";

                EndpointAddress remoteAddress = new EndpointAddress(sURL);

                WS_Sunat.billServiceClient ws = new WS_Sunat.billServiceClient(binding, remoteAddress);

                ws.ClientCredentials.UserName.UserName = "xxxxxxxxx";
                ws.ClientCredentials.UserName.Password = "yyyyyy";

                var elements = ws.Endpoint.Binding.CreateBindingElements();
                elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;
                ws.Endpoint.Binding = new CustomBinding(elements);

                string sNombreZip = "20382748132-01-F001-2121.zip";
                Byte[] bytes = File.ReadAllBytes(@"C:\Joel\Proyectos\20382748132-01-F001-2121.zip");

                byte[] oRespuestaXML = ws.sendBill(sNombreZip, bytes);

                Console.WriteLine(Encoding.UTF8.GetString(oRespuestaXML));

    app.config 

        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BillServicePortBinding">
                        <security mode="Transport" />
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="https://www.sunat.gob.pe:443/ol-ti-itcpgem-sqa/billService"
                    binding="basicHttpBinding" bindingConfiguration="BillServicePortBinding"
                    contract="WS_Sunat.billService" name="BillServicePort" />
            </client>
        </system.serviceModel>
    Thursday, January 14, 2016 7:43 PM
  • Estimados tengo el bendito error en lo que es la homologacion por favor necesito de su ayuda

    Espero que me puedan ayudar 

    El Error :

    La respuesta de Error es :  - 

    En el detalle : 

                        Code Name : 0103

    Codigo :

                System.Net.ServicePointManager.UseNagleAlgorithm = true;
                System.Net.ServicePointManager.Expect100Continue = false;
                System.Net.ServicePointManager.CheckCertificateRevocationList = true;

                BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;

                string sURL = "https://www.sunat.gob.pe:443/ol-ti-itcpgem-sqa/billService";

                EndpointAddress remoteAddress = new EndpointAddress(sURL);

                WS_Sunat.billServiceClient ws = new WS_Sunat.billServiceClient(binding, remoteAddress);

                ws.ClientCredentials.UserName.UserName = "xxxxxxxxx";
                ws.ClientCredentials.UserName.Password = "yyyyyy";

                var elements = ws.Endpoint.Binding.CreateBindingElements();
                elements.Find<SecurityBindingElement>().EnableUnsecuredResponse = true;
                ws.Endpoint.Binding = new CustomBinding(elements);

                string sNombreZip = "20382748132-01-F001-2121.zip";
                Byte[] bytes = File.ReadAllBytes(@"C:\Joel\Proyectos\20382748132-01-F001-2121.zip");

                byte[] oRespuestaXML = ws.sendBill(sNombreZip, bytes);

                Console.WriteLine(Encoding.UTF8.GetString(oRespuestaXML));

    app.config 

        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BillServicePortBinding">
                        <security mode="Transport" />
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="https://www.sunat.gob.pe:443/ol-ti-itcpgem-sqa/billService"
                    binding="basicHttpBinding" bindingConfiguration="BillServicePortBinding"
                    contract="WS_Sunat.billService" name="BillServicePort" />
            </client>
        </system.serviceModel>
    Thursday, January 14, 2016 7:44 PM