locked
Need Web Service help for calling a method when XML incoming from external source RRS feed

  • Question

  • User1098464520 posted

    First - I must apologize - I have not worked in web development in 8.5 years. I have been working in software development and have never build a web service.

    I am running a vb/asp.net 4.5 environment web server.

    When setting up the server and to make sure I could get a web service to work, I used the Fahrenheit to Celsius TempConvert and debugged the web config file to make sure everything is working. (http://sierraproductioncenter.com/WebForm1.aspx)

    We have an outside vendor who wants to send us XML files to be consumed on our side so I can parse them and feed our DB. My thought on this is I should just need to save the incoming file onto the web server to a file.  I can then loop through the files, validate, and feed data to the SQL DB.

    After poking around for 2 days, I found some code that looks like I should be able to save a file to a TempFileName.

     <WebMethod()> Public Function GetTempFileName() As String
            Dim g As Guid = New Guid
            Dim fs As FileStream = New FileStream(Server.MapPath(g.ToString()), FileMode.Create)
            fs.Close()
    
            Return g.ToString()
        End Function
    
        <WebMethod()> Public Sub AppendToTempFile(ByVal filename As String, ByVal data As Byte)
            Try
                Dim fs As FileStream = New FileStream(Server.MapPath(filename), FileMode.Append)
                Dim bw As BinaryWriter = New BinaryWriter(fs)
                bw.Write(data)
                bw.Close()
                fs.Close()
    
            Catch ex As Exception
                Throw New Exception("Append to TempFile " + ex.ToString)
            End Try
    
        End Sub

    The issue is - how do I call the method(s) without creating a form action/button on an .aspx?

    In theory, shouldn't they be able to send to a web address or does it need to have some kind of form action?

    Thursday, July 27, 2017 9:04 PM

Answers

  • User1098464520 posted

    Hi AmznQueenLJM,

    >> how do I call the method(s) without creating a form action/button on an .aspx?

    What do you mean by without creating a form action?

    Where do you want to call this method?

    Based on your code, it is used to save file data to temp file. And it seems this method will be called by outside vendor.

    For you, you need to expose this service to vendor by hosting it in a public address and tell them the service address.

    For vendor, they will create an application like console application and add service reference by your service address and then consume your service.

    For a simple demo which create service and consume service, you could refer below link.

    #HOW TO: Write a Simple Web Service by Using Visual C# .NET

    https://support.microsoft.com/en-us/help/308359/how-to-write-a-simple-web-service-by-using-visual-c--net 

    Best Regards,

    Edward

    Edward - in that brief reply you explained so much.  I don't have to worry about how they access the web service - just that the service is exposed and runs on the web server and can accept a document to save to the server.

    The help they gave for requirements was ZERO.  I had no idea what they expected.

    Question - when I worked for the State of TX we had a private T-Line where the offices in Austin sent us SPL files to a server print spooler with a specified file name requirements.  I can do something similar here right?  If document name coming in doesn't contain???

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 28, 2017 3:21 PM

All replies

  • User1168443798 posted

    Hi AmznQueenLJM,

    >> how do I call the method(s) without creating a form action/button on an .aspx?

    What do you mean by without creating a form action?

    Where do you want to call this method?

    Based on your code, it is used to save file data to temp file. And it seems this method will be called by outside vendor.

    For you, you need to expose this service to vendor by hosting it in a public address and tell them the service address.

    For vendor, they will create an application like console application and add service reference by your service address and then consume your service.

    For a simple demo which create service and consume service, you could refer below link.

    #HOW TO: Write a Simple Web Service by Using Visual C# .NET

    https://support.microsoft.com/en-us/help/308359/how-to-write-a-simple-web-service-by-using-visual-c--net 

    Best Regards,

    Edward

    Friday, July 28, 2017 7:27 AM
  • User1098464520 posted

    Hi AmznQueenLJM,

    >> how do I call the method(s) without creating a form action/button on an .aspx?

    What do you mean by without creating a form action?

    Where do you want to call this method?

    Based on your code, it is used to save file data to temp file. And it seems this method will be called by outside vendor.

    For you, you need to expose this service to vendor by hosting it in a public address and tell them the service address.

    For vendor, they will create an application like console application and add service reference by your service address and then consume your service.

    For a simple demo which create service and consume service, you could refer below link.

    #HOW TO: Write a Simple Web Service by Using Visual C# .NET

    https://support.microsoft.com/en-us/help/308359/how-to-write-a-simple-web-service-by-using-visual-c--net 

    Best Regards,

    Edward

    Edward - in that brief reply you explained so much.  I don't have to worry about how they access the web service - just that the service is exposed and runs on the web server and can accept a document to save to the server.

    The help they gave for requirements was ZERO.  I had no idea what they expected.

    Question - when I worked for the State of TX we had a private T-Line where the offices in Austin sent us SPL files to a server print spooler with a specified file name requirements.  I can do something similar here right?  If document name coming in doesn't contain???

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 28, 2017 3:21 PM
  • User1168443798 posted

    Hi AmznQueenLJM,

    >> I don't have to worry about how they access the web service

    It seems there is no issue for your original issue, am I right? If so, I would suggest you mark the helpful reply as answer which is the way to close an thread here.

    >> If document name coming in doesn't contain???

    What do you mean by this? Do you mean you want to pass file with file name? If so, you can.

    If you have any issue for this new issue, I would suggest you post a new thread which is recommended one issue in one thread.

    Best Regards,

    Edward

    Monday, July 31, 2017 2:33 AM