Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Asmx Web Service with Soap 1.2

Posted on 2014-04-04
4
Medium Priority
?
1,185 Views
Last Modified: 2016-02-26
I'm creating an asmx web service for a solution about receiving online invoices. Invoice sender (client) wants me to make my service as soap 1.2.

My default web service's binding is like below:
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

Open in new window


As you see, it says basic profile v1.1 ... But when I checked basic profile v1.1, I just sow only supports soap 1.1 , I need 1.2 and I have to use wsi profile. There is wsi profile 2.0 version at their web site ( http://ws-i.org/Profiles/BasicProfile-2.0-2010-11-09.html ) but I don't know how to use it in c# asmx web service. Can you help? (Full code below.)


using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
using EFaturaMaker.EFaturaService;

namespace PostboxWS
{
    /// <summary>
    /// Summary description for Postbox
    /// </summary>
    [WebService(Namespace = "http://gib.gov.tr/vedop3/eFatura")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Postbox : System.Web.Services.WebService
    {

        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.Web.Services.WebServiceBindingAttribute(Name = "EFaturaSoapBinding", Namespace = "http://gib.gov.tr/vedop3/eFatura")]
        public interface IEFaturaSoapBinding
        {

            /// <remarks/>
            [System.Web.Services.WebMethodAttribute()]
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("getApplicationResponse", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
            [return: System.Xml.Serialization.XmlElementAttribute("getAppRespResponse", Namespace = "http://gib.gov.tr/vedop3/eFatura")]
            getAppRespResponseType getApplicationResponse([System.Xml.Serialization.XmlElementAttribute(Namespace = "http://gib.gov.tr/vedop3/eFatura")] getAppRespRequestType getAppRespRequest);

            /// <remarks/>
            [System.Web.Services.WebMethodAttribute()]
            [System.Web.Services.Protocols.SoapDocumentMethodAttribute("sendDocument", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
            [return: System.Xml.Serialization.XmlElementAttribute("documentResponse", Namespace = "http://gib.gov.tr/vedop3/eFatura")]
            documentReturnType sendDocument([System.Xml.Serialization.XmlElementAttribute(Namespace = "http://gib.gov.tr/vedop3/eFatura")] documentType documentRequest);
        }

        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://gib.gov.tr/vedop3/eFatura")]
        public partial class getAppRespRequestType
        {

            private string instanceIdentifierField;

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string instanceIdentifier
            {
                get
                {
                    return this.instanceIdentifierField;
                }
                set
                {
                    this.instanceIdentifierField = value;
                }
            }
        }

        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://gib.gov.tr/vedop3/eFatura")]
        public partial class documentReturnType
        {

            private string msgField;

            private string hashField;

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string msg
            {
                get
                {
                    return this.msgField;
                }
                set
                {
                    this.msgField = value;
                }
            }

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string hash
            {
                get
                {
                    return this.hashField;
                }
                set
                {
                    this.hashField = value;
                }
            }
        }

        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.w3.org/2005/05/xmlmime")]
        public partial class base64Binary
        {

            private string contentTypeField;

            private byte[] valueField;

            /// <remarks/>
            [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
            public string contentType
            {
                get
                {
                    return this.contentTypeField;
                }
                set
                {
                    this.contentTypeField = value;
                }
            }

            /// <remarks/>
            [System.Xml.Serialization.XmlTextAttribute(DataType = "base64Binary")]
            public byte[] Value
            {
                get
                {
                    return this.valueField;
                }
                set
                {
                    this.valueField = value;
                }
            }
        }

        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://gib.gov.tr/vedop3/eFatura")]
        public partial class documentType
        {

            private string fileNameField;

            private base64Binary binaryDataField;

            private string hashField;

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string fileName
            {
                get
                {
                    return this.fileNameField;
                }
                set
                {
                    this.fileNameField = value;
                }
            }

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public base64Binary binaryData
            {
                get
                {
                    return this.binaryDataField;
                }
                set
                {
                    this.binaryDataField = value;
                }
            }

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string hash
            {
                get
                {
                    return this.hashField;
                }
                set
                {
                    this.hashField = value;
                }
            }
        }

        /// <remarks/>
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://gib.gov.tr/vedop3/eFatura")]
        public partial class getAppRespResponseType
        {

            private string applicationResponseField;

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
            public string applicationResponse
            {
                get
                {
                    return this.applicationResponseField;
                }
                set
                {
                    this.applicationResponseField = value;
                }
            }
        }


        
        [WebMethod]
        public documentReturnType sendDocument(documentType documentRequest)
        {
            var dcRtrn = new documentReturnType();
            try
            {
                string sSource;
                string sLog;
                string sEvent;

                sSource = "TEST";
                sLog = "Application";
                sEvent = "Sample TEST EFATURA";

                if (!EventLog.SourceExists(sSource))
                    EventLog.CreateEventSource(sSource, sLog);

                EventLog.WriteEntry(sSource, sEvent);
                EventLog.WriteEntry(sSource, sEvent,
                    EventLogEntryType.Warning, 234);

                dcRtrn.hash = documentRequest.hash;
                dcRtrn.msg = "BASARIYLA ISLENDI";
                return dcRtrn;

                if (documentRequest.binaryData != null)
                {
                    string WCzipPath = WebConfigurationManager.AppSettings["RecieveBatPath"];
                    var rtrn = EFaturaMaker.ParseEnvelope.saveZipFile(documentRequest.binaryData.Value, documentRequest.fileName, WCzipPath);
                    if (rtrn != null)
                    {
                        dcRtrn.hash = documentRequest.hash;
                        dcRtrn.msg = rtrn;
                        return dcRtrn;
                    }
                }
            }
            catch (Exception ex)
            {
                dcRtrn.msg = ex.Message;
                return dcRtrn;
            }
            return dcRtrn;
        }

        [WebMethod]
        public getAppRespResponseType getApplicationResponse(getAppRespRequestType getAppRespRequest)
        {
            var rtn = new getAppRespResponseType();
            rtn.applicationResponse = @"test1234567890";
            return rtn;
        }

    }
}

Open in new window

0
Comment
Question by:Rudewind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 39978527
0
 

Author Comment

by:Rudewind
ID: 39978711
Nope it didn't help, the exactly errors I get when I trace the Web Service are:

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Warning">0</SubType><Level>4</Level><TimeCreated SystemTime="2014-04-04T17:18:48.2140499Z" /><Source Name="System.Web.Services.Asmx" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /><Execution ProcessName="w3wp" ProcessID="1408" ThreadID="20" /><Channel /><Computer>EFATURA</Computer></System><ApplicationData>Exception caught in System.Web.Services.Protocols.SoapServerProtocolFactory#66483446::Create.
    System.Xml.XmlException: Data at the root level is invalid. Line 2, position 1.</ApplicationData></E2ETraceEvent>

Open in new window


and

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Warning">0</SubType><Level>4</Level><TimeCreated SystemTime="2014-04-04T17:18:48.2140499Z" /><Source Name="System.Web.Services.Asmx" /><Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /><Execution ProcessName="w3wp" ProcessID="1408" ThreadID="20" /><Channel /><Computer>EFATURA</Computer></System><ApplicationData>Exception Details:
System.Xml.XmlException: Data at the root level is invalid. Line 2, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlTextReader.Read()
   at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()
   at System.Xml.XmlReader.MoveToContent()
   at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()
   at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()
   at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type ty...</ApplicationData></E2ETraceEvent>

Open in new window

0
 

Accepted Solution

by:
Rudewind earned 0 total points
ID: 39979910
I solved it by using wsdl file. Run wsdl file with wsdl exe. It generated a cs file for me with contracts and interface. I used that cs file in asmx.cs and its done.
0
 

Author Closing Comment

by:Rudewind
ID: 39991105
Did it by myself.
0

Featured Post

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot has fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question