VB.NET WCF Soap Web服务变量丢失

时间:2010-07-27 19:49:08

标签: xml vb.net wcf soap

我创建了一个WCF VB.Net Soap服务。服务编译并运行,但在运行时,只接收通过soap请求传递给函数的一半变量。是否有人能够帮助我确定为什么只传递部分变量。提前感谢。

接口

Imports System.ServiceModel
Imports System.ServiceModel.Web

<ServiceContract(Namespace:="http://tms.m33integrated.com/")> _
Public Interface IRateService

    <WebInvoke(Method:="POST"), OperationContract(Action:="http://tms.m33integrated.com/RateShop")> _
    Function RateShop(ByVal rateRequest As RateRequest) As ShoppedRate()

    <WebInvoke(Method:="POST"), OperationContract(Action:="http://tms.m33integrated.com/RateShipment")> _
    Function RateShipment(ByVal rr As RateRequest) As Rate

    <WebInvoke(Method:="POST"), OperationContract(Action:="http://tms.m33integrated.com/RateMultiStopShipment")> _
    Function RateMultiStopShipment(ByVal rr As MultiStopRateRequest) As MultiStopRate

    <WebInvoke(Method:="POST"), OperationContract(Action:="http://tms.m33integrated.com/RateShopMultiStopShipment")> _
    Function RateShopMultiStopShipment(ByVal msrr As MultiStopRateShopRequest) As MultiStopRates

End Interface

实施

Imports System.IO
Imports System.Net
Imports System.Web
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Script.Serialization
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Json
Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.Configuration

<ServiceBehavior(ConcurrencyMode:=ConcurrencyMode.Single, InstanceContextMode:=InstanceContextMode.Single)> _
Public Class RateService
    Implements IRateService

    Public Function RateShop(ByVal rateRequest As RateRequest) As ShoppedRate() Implements IRateService.RateShop

    End Function


    '
    ' A remote method to rate a single load.
    '
    Public Function RateShipment(ByVal rr As RateRequest) As Rate Implements IRateService.RateShipment

    End Function

    Public Function RateMultiStopShipment(ByVal rr As MultiStopRateRequest) As MultiStopRate Implements IRateService.RateMultiStopShipment

    End Function

    Public Function RateShopMultiStopShipment(ByVal msrr As MultiStopRateShopRequest) As MultiStopRates Implements IRateService.RateShopMultiStopShipment

    End Function
End Class
<DataContract(Namespace:="http://tms.m33integrated.com")> _
Public Class LoadDetail
    <DataMember()>
    Public freightClass As String
    <DataMember()>
    Public weight As String
    <DataMember()>
    Public palletCount As String
    <DataMember()>
    Public linearFeet As String
End Class

<DataContract(Namespace:="http://tms.m33integrated.com")> _
Public Class Accessorial
    <DataMember()>
    Public name As String
    <DataMember()>
    Public argCount As Integer
    <DataMember()>
    Public value As String
    <DataMember()>
    Public value0 As String
    <DataMember()>
    Public passThrough As Boolean
End Class

<DataContract(Namespace:="http://tms.m33integrated.com")> _
Public Class RateRequest
    <DataMember()>
    Public LoadID As String
    <DataMember()>
    Public UserID As String
    <DataMember()>
    Public clientName As String
    <DataMember()>
    Public scac As String           'not used when rate shopping
    <DataMember()>
    Public rateShopCode As String   'only used when rate shopping
    <DataMember()>
    Public mode As String
    <DataMember()>
    Public shipDate As String
    '--------------------------------------------------------------------------------------- ETM /*
    <DataMember()>
    Public miles As String
    <DataMember()>
    Public typePractical As String
    '--------------------------------------------------------------------------------------- ETM */
    <DataMember()>
    Public origin As ShippingPoint
    <DataMember()>
    Public destination As ShippingPoint
    <DataMember()>
    Public details() As LoadDetail
    <DataMember()>
    Public accessorials() As Accessorial
End Class

Public Class Rate
    Public Result As String
    Public Rate As Double
    Public RateACC As Double
    Public RateFUE As Double
    Public TariffName As String
    Public TariffDate As String
    Public Movement As String
    Public TariffMin As String
    Public Miles As String
    Public RatedWt As String
    Public DeficitWt As String
    Public ActualWt As String
    Public RatePerCWT As String
    Public PalletRate As String
    Public FuelCalc As String
    Public DiscPercent As String
    Public GrossAmt As String
    Public DiscAmt As String
    Public LHDiscAmt As String
    Public FuelAmt As String
    Public AccAmt As String
    Public NetAmt As String
    Public serviceType As String
    Public TransitDays As String
    Public mileType As String
    Public RatePerMile As String
    Public FuelFactor As String
    Public MinCharge As String
    Public MinFloor As String
    Public Currency As String
    Public details() As RateShoppedLoadDetail
    Public accessorials() As Accessorial
End Class

Public Class ShoppedRate
    Public rateResultID As String
    Public result As String
    Public clientName As String
    Public DriverUnloads As String
    Public scac As String
    Public mode As String
    Public shipDate As String
    Public origin As ShippingPoint
    Public destination As ShippingPoint
    Public ratedWeight As String
    Public deficitWeight As String
    Public actualWeight As String
    Public tariffWeight As String
    Public tariffDate As String
    Public tariffName As String
    Public ratePerCWT As String
    Public ratePerPalette As String
    Public fuelType As String
    Public mileType As String
    Public minFloor As String
    Public discountPercent As String
    Public fuelFactor As String
    Public tariffMin As String
    Public totalMiles As String
    Public grossAmount As String
    Public discountAmount As String
    Public fuelAmount As String
    Public lhDiscountAmount As String
    Public totalAccessorialAmount As String
    Public netAmount As String
    Public movementType As String
    Public serviceType As String
    Public TransitDays As String
    Public Currency As String
    Public details() As RateShoppedLoadDetail
    Public accessorials() As Accessorial
End Class


Public Class RateShoppedLoadDetail
    Public freightClass As String
    Public weight As String
    Public palletCount As String
    Public linearFeet As String
    Public fak As String
    Public rate As String
    Public detailGrossAmount As String
    Public detailNetAmount As String
    Public detailDeficitWeight As String
    Public cubicFeet As String
End Class

<DataContract(Namespace:="http://tms.m33integrated.com")> _
Public Class MultiStopRateRequest
    <DataMember()>
    Public LoadID As String
    <DataMember()>
    Public UserID As String
    <DataMember()>
    Public clientName As String
    <DataMember()>
    Public scac As String
    <DataMember()>
    Public mode As String
    <DataMember()>
    Public shipDate As String
    <DataMember()>
    Public driverUnloads As String
    <DataMember()>
    Public Resequence As String
    <DataMember()>
    Public DestinationFixed As String
    <DataMember()>
    Public UsePRMiles As String
    <DataMember()>
    Public LockFirst As String
    <DataMember()>
    Public segment() As Segment
End Class

<DataContract(Namespace:="http://tms.m33integrated.com")> _
Public Class Segment
    <DataMember()>
    Public origin As ShippingPoint
    <DataMember()>
    Public destination As ShippingPoint
    '--------------------------------------------------------------------------------------- ETM /*
    <DataMember()>
    Public miles As String          ' 05/27/2010 added miles so milage can be directly passed to the rater
    '--------------------------------------------------------------------------------------- ETM */
    <DataMember()>
    Public details() As LoadDetail
    <DataMember()>
    Public accessorials() As Accessorial
End Class

Public Class RatedSegment
    Public MovementType As String
    Public DriverUnloads As String
    Public TotalLinearFeet As String
    Public MileType As String
    Public RatedWeight As String
    Public ActualWeight As String
    Public TotalNoPallets As String
    Public TariffName As String
    Public TariffDate As String
    Public TariffNameCWT As String
    Public TariffDateCWT As String
    Public TariffNamePLT As String
    Public TariffDatePLT As String
    Public RateStatus As String
    Public SegMiles As String
    Public SegCharges As String
    Public StopOffCharges As String
    Public TotalMiles As String
    Public FuelType As String
    Public RatePerCWT As String
    Public RatePerMile As String
    Public RatePerMileBH As String
    Public FuelFactor As String
    Public MinCharge As String
    Public TransitDays As String
    Public ServiceType As String
    Public GrossAmount As String
    Public FuelAmount As String
    Public TotalAccAmount As String
    Public NetAmount As String
    Public Currency As String
    Public origin As ShippingPoint
    Public destination As ShippingPoint
End Class

Public Class MultiStopRate
    Public result As String
    Public LoadID As String
    Public UserID As String
    Public clientName As String
    Public scac As String
    Public mode As String
    Public shipDate As String
    Public driverUnloads As String
    Public Resequence As String
    Public DestinationFixed As String
    Public UsePRMiles As String
    Public LockFirst As String
    Public segment() As RatedSegment
End Class

<DataContract(Namespace:="http://tms.m33integrated.com")> _
Public Class MultiStopRateShopRequest
    <DataMember()>
    Public LoadID As String
    <DataMember()>
    Public UserID As String
    <DataMember()>
    Public clientName As String
    <DataMember()>
    Public scacs() As String
    <DataMember()>
    Public mode As String
    <DataMember()>
    Public shipDate As String
    <DataMember()>
    Public driverUnloads As String
    <DataMember()>
    Public Resequence As String
    <DataMember()>
    Public DestinationFixed As String
    <DataMember()>
    Public UsePRMiles As String
    <DataMember()>
    Public LockFirst As String
    <DataMember()>
    Public segment() As Segment
End Class

Public Class MultiStopRates
    Public Result As String
    Public MultiStopRate() As MultiStopRate
End Class

'--------------------------------------------------------------------------------------- ETM /*
Public Class Leg
    Public distance As Double
    Public time As Double
    Public origin As String
    Public destination As String
End Class

Public Class PCMiler_Return
    Public distance As Double
    Public errorMessage As String
    Public time As Double
    Public legList As System.Collections.Generic.List(Of Leg)
End Class

Public Class Carrier
    Public name As String
    Public lastUpdate As String
    Public type As String
    Public SCAC As String
    Public contact As Contact
End Class

Public Class Terminal
    Public name As String
    Public contact As Contact
End Class

Public Class Contact
    Public city As String
    Public name As String
    Public title As String
    Public email As String
    Public phoneNumbers As System.Collections.Generic.List(Of PhoneNumber)
    Public postalCode As String
    Public stateRegion As String
    Public street1 As String
    Public street2 As String
End Class

Public Class PhoneNumber
    Public number As String
    Public type As String
End Class

Public Class CarrierConnect_Return
    Public errorMessage As String
    Public origin As String
    Public destination As String
    Public originServiceType As String
    Public destinationServiceType As String
    Public directService As String
    Public serviceDays As String
    Public carrierInformation As Carrier
    Public originTerminalInformation As Terminal
    Public destinationTerminalInformation As Terminal
End Class

.Config File

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="RaterWebService.Service1Behavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="RaterWebService.Service1Behavior"
                name="RaterWebService.RateService">
                <endpoint address="" binding="basicHttpBinding" contract="RaterWebService.IRateService" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8080/" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>
</configuration>

正在发送肥皂请求

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <RateShop xmlns="http://tms.m33integrated.com/">
      <rateRequest xmlns:tms="http://tms.m33integrated.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <tms:LoadID></tms:LoadID>
    <tms:UserID>49277</tms:UserID>
        <tms:accessorials>
        <tms:Accessorial>
                <tms:name></tms:name>
            </tms:Accessorial>
        </tms:accessorials>
        <tms:clientName>Acucote Inc</tms:clientName>
        <tms:destination>
        <tms:city>Greenville</tms:city>
        <tms:country>USA</tms:country>   
        <tms:postalCode>29614</tms:postalCode>
        <tms:state>SC</tms:state>
    </tms:destination>
        <tms:details>
        <tms:LoadDetail>
                <tms:freightClass>55</tms:freightClass>
                <tms:linearFeet>0</tms:linearFeet>
                <tms:palletCount>0</tms:palletCount>
                <tms:weight>500</tms:weight>
            </tms:LoadDetail>
    </tms:details>
        <tms:miles></tms:miles>
        <tms:mode>LTL</tms:mode>
        <tms:origin>
        <tms:city>Gaffney</tms:city>
        <tms:country>USA</tms:country>
        <tms:postalCode>29340</tms:postalCode>
        <tms:state>SC</tms:state>
    </tms:origin>
        <tms:rateShopCode>6</tms:rateShopCode>
        <tms:scac></tms:scac>
        <tms:shipDate>07/23/2010</tms:shipDate>
        <tms:typePractical></tms:typePractical>
      </rateRequest>
    </RateShop>
  </s:Body>
</s:Envelope>

1 个答案:

答案 0 :(得分:0)

没关系,显然在WCF中你的soap变量必须进行alphabatized。 = p .NET