Link to home
Start Free TrialLog in
Avatar of Dan
DanFlag for United States of America

asked on

asp.net VB HttpWebRequest Soap transaction

This is my first shot at a SOAP request using the HttpWebRequest .  Not Having any success.  The only thing I'm getting is a error message.

"The remote server returned an error: (500) Internal Server Error."

The SOAP transaction is an actual sample downloaded from FEDX and the credentials are valid for testing.

Any help, assistance or samples will be greatly appreciated.

Thank You

-dan



   

        
        Dim URlis As String = ("https://wsbeta.fedex.com:443/web-services")
        Dim SoapReq As HttpWebRequest = HttpWebRequest.Create(URlis)

       
        Dim soapstr As String = Nothing
        Dim strbldr As New StringBuilder

        strbldr.Append("<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns=""http://fedex.com/ws/rate/v18"">")
        strbldr.Append("<SOAP-ENV:Body>")
        strbldr.Append("<RateRequest>")
        strbldr.Append("<WebAuthenticationDetail>")
        strbldr.Append("<UserCredential>")
        strbldr.Append("<Key>73QRrebbeiDncdMg</Key>")
        strbldr.Append("<Password>7YWBGQfgxzhV0yBY8COsu5Fpj</Password>")
        strbldr.Append("</UserCredential>")
        strbldr.Append(" </WebAuthenticationDetail>")
        strbldr.Append("<ClientDetail>")
        strbldr.Append(" <AccountNumber>510087020</AccountNumber>")
        strbldr.Append("<MeterNumber>100011727</MeterNumber>")
        strbldr.Append("</ClientDetail>")
        strbldr.Append("         <TransactionDetail>")
        strbldr.Append("            <CustomerTransactionId>INTERNATIONAL_PRIORITY_FREIGHTwithYourPackaging</CustomerTransactionId>")
        strbldr.Append("         </TransactionDetail>")
        strbldr.Append("         <Version>")
        strbldr.Append("            <ServiceId>crs</ServiceId>")
        strbldr.Append("            <Major>18</Major>")
        strbldr.Append("            <Intermediate>0</Intermediate>")
        strbldr.Append("            <Minor>0</Minor>")
        strbldr.Append("         </Version>")
        strbldr.Append("         <RequestedShipment>")
        strbldr.Append("            <ShipTimestamp>2014-05-23T12:34:56-06:00</ShipTimestamp>")
        strbldr.Append("            <DropoffType>REGULAR_PICKUP</DropoffType>")
        strbldr.Append("            <ServiceType>INTERNATIONAL_PRIORITY_FREIGHT</ServiceType>")
        strbldr.Append("            <PackagingType>YOUR_PACKAGING</PackagingType>")
        strbldr.Append("            <PreferredCurrency>USD</PreferredCurrency>")
        strbldr.Append("            <Shipper>")
        strbldr.Append("               <Contact>")
        strbldr.Append("                  <CompanyName>Input Your Information</CompanyName>")
        strbldr.Append("                  <PhoneNumber>Input Your Information</PhoneNumber>")
        strbldr.Append("               </Contact>")
        strbldr.Append("               <Address>")
        strbldr.Append("                  <StreetLines>Input Your Information</StreetLines>")
        strbldr.Append("                  <StreetLines>Input Your Information</StreetLines>")
        strbldr.Append("                  <City>MEMPHIS</City>")
        strbldr.Append("                  <StateOrProvinceCode>TN</StateOrProvinceCode>")
        strbldr.Append("                  <PostalCode>38101</PostalCode>")
        strbldr.Append("                  <CountryCode>US</CountryCode>")
        strbldr.Append("               </Address>")
        strbldr.Append("            </Shipper>")
        strbldr.Append("            <Recipient>")
        strbldr.Append("               <Contact>")
        strbldr.Append("                  <PersonName>Input Your Information</PersonName>")
        strbldr.Append("                  <PhoneNumber>Input Your Information</PhoneNumber>")
        strbldr.Append("               </Contact>")
        strbldr.Append("               <Address>")
        strbldr.Append("                  <StreetLines>Input Your Information</StreetLines>")
        strbldr.Append("                  <StreetLines>Input Your Information</StreetLines>")
        strbldr.Append("                  <City>RICHMOND</City>")
        strbldr.Append("                  <StateOrProvinceCode>BC</StateOrProvinceCode>")
        strbldr.Append("                  <PostalCode>V7C4v7</PostalCode>")
        strbldr.Append("                  <CountryCode>CA</CountryCode>")
        strbldr.Append("               </Address>")
        strbldr.Append("            </Recipient>")
        strbldr.Append("            <ShippingChargesPayment>")
        strbldr.Append("               <PaymentType>SENDER</PaymentType>")
        strbldr.Append("               <Payor>")
        strbldr.Append("                  <ResponsibleParty>")
        strbldr.Append("                     <AccountNumber>Input Your Information</AccountNumber>")
        strbldr.Append("                  </ResponsibleParty>")
        strbldr.Append("               </Payor>")
        strbldr.Append("            </ShippingChargesPayment>")
        strbldr.Append("            <ExpressFreightDetail>")
        strbldr.Append("               <PackingListEnclosed>1</PackingListEnclosed>")
        strbldr.Append("               <ShippersLoadAndCount>2</ShippersLoadAndCount>")
        strbldr.Append("               <BookingConfirmationNumber>123asd789</BookingConfirmationNumber>")
        strbldr.Append("            </ExpressFreightDetail>")
        strbldr.Append("            <CustomsClearanceDetail>")
        strbldr.Append("               <DutiesPayment>")
        strbldr.Append("                  <PaymentType>SENDER</PaymentType>")
        strbldr.Append("                  <Payor>")
        strbldr.Append("                     <ResponsibleParty>")
        strbldr.Append("                        <AccountNumber>Input Your Information</AccountNumber>")
        strbldr.Append("                     </ResponsibleParty>")
        strbldr.Append("                  </Payor>")
        strbldr.Append("               </DutiesPayment>")
        strbldr.Append("               <DocumentContent>DOCUMENTS_ONLY</DocumentContent>")
        strbldr.Append("               <CustomsValue>")
        strbldr.Append("                  <Currency>USD</Currency>")
        strbldr.Append("                  <Amount>100.00</Amount>")
        strbldr.Append("               </CustomsValue>")
        strbldr.Append("               <CommercialInvoice>")
        strbldr.Append("                  <TermsOfSale>FOB_OR_FCA</TermsOfSale>")
        strbldr.Append("               </CommercialInvoice>")
        strbldr.Append("               <Commodities>")
        strbldr.Append("                  <NumberOfPieces>1</NumberOfPieces>")
        strbldr.Append("                  <Description>ABCD</Description>")
        strbldr.Append("                  <CountryOfManufacture>US</CountryOfManufacture>")
        strbldr.Append("                  <Weight>")
        strbldr.Append("                     <Units>LB</Units>")
        strbldr.Append("                     <Value>1.0</Value>")
        strbldr.Append("                  </Weight>")
        strbldr.Append("                  <Quantity>1</Quantity>")
        strbldr.Append("                  <QuantityUnits>cm</QuantityUnits>")
        strbldr.Append("                  <UnitPrice>")
        strbldr.Append("                     <Currency>USD</Currency>")
        strbldr.Append("                     <Amount>1000.00</Amount>")
        strbldr.Append("                  </UnitPrice>")
        strbldr.Append("                  <CustomsValue>")
        strbldr.Append("                     <Currency>USD</Currency>")
        strbldr.Append("                     <Amount>100.000000</Amount>")
        strbldr.Append("                  </CustomsValue>")
        strbldr.Append("               </Commodities>")
        strbldr.Append("               <ExportDetail>")
        strbldr.Append("                  <ExportComplianceStatement>30.37(f)</ExportComplianceStatement>")
        strbldr.Append("               </ExportDetail>")
        strbldr.Append("            </CustomsClearanceDetail>")
        strbldr.Append("            <RateRequestTypes>LIST</RateRequestTypes>")
        strbldr.Append("            <PackageCount>1</PackageCount>")
        strbldr.Append("            <RequestedPackageLineItems>")
        strbldr.Append("               <SequenceNumber>1</SequenceNumber>")
        strbldr.Append("               <GroupNumber>1</GroupNumber>")
        strbldr.Append("               <GroupPackageCount>1</GroupPackageCount>")
        strbldr.Append("               <Weight>")
        strbldr.Append("                  <Units>LB</Units>")
        strbldr.Append("                  <Value>158.0</Value>")
        strbldr.Append("               </Weight>")
        strbldr.Append("               <Dimensions>")
        strbldr.Append("                  <Length>12</Length>")
        strbldr.Append("                  <Width>12</Width>")
        strbldr.Append("                  <Height>12</Height>")
        strbldr.Append("                  <Units>IN</Units>")
        strbldr.Append("               </Dimensions>")
        strbldr.Append("               <CustomerReferences>")
        strbldr.Append("                  <CustomerReferenceType>CUSTOMER_REFERENCE</CustomerReferenceType>")
        strbldr.Append("                  <Value>TC001_01_PT1_ST01_PK01_SNDUS_RCPCA_POS</Value>")
        strbldr.Append("               </CustomerReferences>")
        strbldr.Append("            </RequestedPackageLineItems>")
        strbldr.Append("         </RequestedShipment>")
        strbldr.Append("      </RateRequest>")
        strbldr.Append("   </SOAP-ENV:Body>")
        strbldr.Append("</SOAP-ENV:Envelope>")


        soapstr = strbldr.ToString


        Try
            Dim response As HttpWebResponse = SoapReq.GetResponse()

            If response.StatusCode = HttpStatusCode.OK Then
                Dim responseStream As IO.StreamReader = New IO.StreamReader(response.GetResponseStream())
                soapstr = responseStream.ReadToEnd()

            Else
                Me.Label1.Text = response.StatusDescription

            End If

        Catch ex As Exception
            Me.Label1.Text = ex.Message
        End Try

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dan

ASKER

Ok I downloaded a WSDL file from FEDX.  I've added it to a new Project using a WSDL to Proxy Class Tool.  I'm not seeing any classes that were generated though.  Would I need to select any particular options with that tool.

thanks

-dan
Hi, sorry but your comment had been lost in my inbox. Do you still have a problem with this, or have you figured it out? Let me know if you still need help.

Giannis