Link to home
Create AccountLog in
Avatar of ross13
ross13Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Create a soap envelope

Hi,

I am working on integrating with parcelforce and was given a wsdl file. When I have integrated this into my visual studio solution I am unable to see any methods for calling the required functions.

I am thinking of manually trying to create a soap as I have used a tool called SoapUI and this works very well. I am trying to test if this would work by saving the xml request in a text file and trying to post it but without much luck.

When ever I have done any web service work before I have been able to reference the service directly and it works calling the methods in the service.


I have been trying the following as I am running out of ideas. I have attached the .wsdl file if anyone has a better idea how to integrate.

   Dim objHTTPReq As HttpWebRequest
            Dim objHTTPRes As HttpWebResponse


            objHTTPReq = CType(WebRequest.CreateDefault(New System.Uri("http://Expresslink-test.parcelforce.net/ws HTTP/1.1")), HttpWebRequest)
            objHTTPReq.ContentType = "text/xml; charset=""utf-8"""
            objHTTPReq.Headers.Add("soapaction", "createShipment")
            objHTTPReq.Method = "POST"

            objHTTPReq.Credentials = New System.Net.NetworkCredential("test", "test")
            Dim DataString As StringBuilder = New StringBuilder


            '*********************************************************************************************************************************
            Dim s As String = ""
            s = My.Computer.FileSystem.ReadAllText("E:\CreateShip.txt")
           
            '*********************************************************************************************************************************
            Dim Postdata() As Byte = System.Text.Encoding.Default.GetBytes(s)
            objHTTPReq.ContentLength = Postdata.Length

            Dim tempStream As Stream = objHTTPReq.GetRequestStream()
            tempStream.Write(Postdata, 0, Postdata.Length)
            tempStream.Close()


            Dim stream As Stream = objHTTPReq.GetResponse().GetResponseStream()
            Dim reader As New StreamReader(stream)
            Dim response As String = String.Empty

Best regards,

Ross
Avatar of mccarl
mccarl
Flag of Australia image

I'm not a .NET developer but is it possible that it doesn't like the " HTTP/1.1" bit on the end of your URI. Try removing that and see how you go.

trying to post it but without much luck
Generally, it would be a good idea to explain in a bit more detail how something is failing, "without much luck" is not much to go on. Do you get an error message? Does it just return something that you aren't expecting? etc, etc.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of ross13

ASKER

I got this to work at last.

Regards

Ross