Avatar of Peter Nordberg
Peter Nordberg
Flag for Sweden asked on

Sending xml request to a webservice

Hi,

I have to do an integration from a business system to a webservice. I'm supposed to send a code in xml to the webservice at this address:

http://dev.memnonnetworks.com/ws/services/ConsignmentWS?wsdl

Then I'm supposed to get a response.

The xml I have already created like this:
        Dim path As String = "c:\memnon.xml"
        Dim writer As New XmlTextWriter(Server.MapPath("memnon.xml"), Encoding.GetEncoding(28591))
        ' start writing!
        writer.Formatting = Formatting.Indented
        'ResponseEncoding = "iso-8859-1"
        writer.WriteStartDocument()


        writer.WriteStartElement("ConsignmentList")


        For Each item As GridDataItem In RadGrid1.Items
            If item.Selected Then
                Dim id As HiddenField = DirectCast(item.FindControl("id"), HiddenField)

                Dim c As New orderDBL
                c.GetPacsoftByID(id.Value)

                Dim cTotal As New orderDBL
                cTotal.GetOrderTotal(id.Value)

                ' ---- Authentication
                writer.WriteStartElement("AuthenticationToken")
                ' ---Username
                writer.WriteStartElement("userName")
                writer.WriteString("user")
                writer.WriteEndElement() ' userName
                ' -- groupname
                writer.WriteStartElement("groupName")
                writer.WriteString("groupname")
                writer.WriteEndElement() ' end groupname
                '-- password
                writer.WriteStartElement("password")
                writer.WriteString("password")
                writer.WriteEndElement() ' end password

                writer.WriteEndElement() ' end Authentication


                '--- Consignment
                writer.WriteStartElement("Consignment")
                writer.WriteAttributeString("orderNo", c.orderID)
                writer.WriteAttributeString("templateName", "Package")

                ' --- Part
                writer.WriteStartElement("Part")
                writer.WriteAttributeString("role", "consignee")

                ' ---Address
                writer.WriteStartElement("Address")

                ' id
                writer.WriteStartElement("id")
                writer.WriteString(c.customerID)
                writer.WriteEndElement() ' end id

                ' Name
                writer.WriteStartElement("name")
                writer.WriteString(c.FirstName & " " & c.LastName)
                writer.WriteEndElement() ' --- end name

                ' adress
                writer.WriteStartElement("address")
                writer.WriteString(c.Address)
                writer.WriteEndElement() ' -- end address

                ' postcode
                writer.WriteStartElement("postcode")
                writer.WriteString(c.Zip)
                writer.WriteEndElement() ' end postcode

                ' city
                writer.WriteStartElement("city")
                writer.WriteString(c.City)
                writer.WriteEndElement() ' end city

                ' countrycode
                writer.WriteStartElement("countrycode")
                writer.WriteString(c.countryCode)
                writer.WriteEndElement() ' end countrycode

                writer.WriteEndElement() ' --- End Address

                ' -- Communication
                writer.WriteStartElement("Communication")

                ' contactperson
                'writer.WriteStartElement("contactPerson")
                'writer.WriteString("Kalle Persson")
                'writer.WriteEndElement() ' end contactperson

                ' mobile
                writer.WriteStartElement("mobile")
                writer.WriteAttributeString("notify", StrConv(c.alertID, VbStrConv.Lowercase))
                writer.WriteString(c.mobile)
                writer.WriteEndElement() ' end mobile

                writer.WriteEndElement() ' -- End communication

                writer.WriteEndElement() ' --- End part

                ' --- GoodsItem
                writer.WriteStartElement("GoodsItem")

                ' NoOfPackage
                writer.WriteStartElement("noOfPackages")
                writer.WriteString("1")
                writer.WriteEndElement() ' End noOfPackages

                ' weight
                writer.WriteStartElement("weight")
                'writer.WriteString("1")
                writer.WriteEndElement() ' end weight
                writer.WriteEndElement() ' --- End GoodsItem

                ' --- TransportProduct
                writer.WriteStartElement("TransportProduct")
                writer.WriteStartElement("PaymentInstruction")
                writer.WriteAttributeString("value", "P")
                writer.WriteEndElement() ' End paymentInstr
                writer.WriteEndElement() ' --- End Transportproduct

                writer.WriteEndElement() ' --- End consignement

            End If
        Next

        writer.WriteEndElement() ' consignmentList
        writer.WriteEndDocument()      
        writer.Close()

Open in new window


But I'm not sure how to send this request and then handle the response.

The manual is here!
http://www.spedpoint.com/static/specifications/ConsignmentWS(eng).pdf

If someone could just show me how to handle the request and response from the service I would be very grateful.

Peter
ASP.NET

Avatar of undefined
Last Comment
viralpala

8/22/2022 - Mon
viralpala

If you are doing coding in .net then just add the web service in the web reference.
then you need to create object of this and you will find all the methods of that web service.

Let me know if you required code for this.

Give me web service address and the xml request that you have created.

hope this will help you.
BuggyCoder

you are supposed to have a method in webservice which either accepts string(xml string) or xmldocument as parameter.

Here is how to call the webservice dynamically.
http://msdn.microsoft.com/en-us/library/1k1skd40.aspx

You can also use Add web reference in visual studio and add service URL
Peter Nordberg

ASKER
Hi,

Some code would be appreciated. The webservice address is like this:
http://dev.memnonnetworks.com/ws/services/ConsignmentWS?wsdl

The only xml I've created is the one above. In the example they have this xml to make an request but I'm not sure how to use it.
:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.spedpoint.com/consignment/types" xmlns:v1="http://www.spedpoint.com/consignment/types/v1_0">
<soapenv:Header/>
<soapenv:Body>
<typ:book>
<AuthenticationToken>
<userName>user</userName>
<groupName>group</groupName>
<password>password</password>
</AuthenticationToken>
<Consignment orderNo="myorderno" automaticBooking="Y" templateName="testtemplate">
<!--1 or more repetitions:-->
<Part role="consignor" account="accountno">
<Address>
<v1:id>consignorID</v1:id>
<v1:name>consignor name</v1:name>
<!--1 or more repetitions:-->
<v1:address>Testgatan 1</v1:address>
<v1:postcode>11339</v1:postcode>
<v1:city>Stockholm</v1:city>
<v1:countrycode>SE</v1:countrycode>
</Address>
</Part>
<Part role="consignee">
<Address>
<v1:id>consigneeID</v1:id>
<v1:name>consignee name</v1:name>
<!--1 or more repetitions:-->
<v1:address>Testgatan 1</v1:address>
<v1:postcode>11339</v1:postcode>
<v1:city>Stockholm</v1:city>
<v1:countrycode>SE</v1:countrycode>
</Address>
</Part>
<!--1 or more repetitions:-->
<GoodsItem>
<v1:noOfPackages>1</v1:noOfPackages>
<v1:weight>1</v1:weight>
</GoodsItem>
<TransportProduct>
<PaymentInstruction value="P"/>
</TransportProduct>
</Consignment>
<transactionId>transactionid</transactionId>
</typ:book>
</soapenv:Body>
</soapenv:Envelope>

Open in new window


Peter
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
BuggyCoder

SOLUTION
Rose Babu

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.