1

プロジェクト (vs2013 で作成) で定義されたサービス参照があり、AppConfig のバインディングはこのように定義されています。

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IERSAPIService" maxReceivedMessageSize="2147483647"/>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://staging.saffire-online.co.uk/ERSAPIService/ERSAPIService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IERSAPIService"
                contract="ErsTestSite.IERSAPIService" name="BasicHttpBinding_IERSAPIService" />
        </client>
    </system.serviceModel>

このサービス リファレンス内には次の関数があります。

Public Function salesXMLCheck(ByVal xmlString As String) As String Implements ErsTestSite.IERSAPIService.salesXMLCheck
            Return MyBase.Channel.salesXMLCheck(xmlString)
        End Function

次の文字列 ('Hello') をその関数に渡すと、次のように返されます。

<?xml version="1.0" encoding="UTF-8"?>
<ers itemtype="Sales Note" doctype="RET" status="NAK" errorcode="E200 [XML Parse Error]" date="2015-06-10 08:02:42" />

基本的に、サービスは私のメッセージを受け取り、解析し、適切にフォーマットされたxmlではないことを認識し、その旨のメッセージを送り返しました。私の考えでは、少なくともサービスに正常に接続していることを示しています。

ただし、この関数を再度呼び出すと、今度は有効な xml が渡されます。

<?xml version="1.0" encoding="UTF-8"?>
<ers uname="apiuser" pword="apipassword" myAttribute="fooBar" anotherOfMyAttributes="123456">
    <salesnote snType="S" action="INSERT" salesContractRef="" saleDate="20090807" auctionID="14" logBookNums="" landingDecNums="" vesselName="SEA ANGEL" vesselPln="TN103" vesselMasterOwner="ARRANBRAE LTD" landingDate1="20090807" landingDate2="" landingDate3="" countryOfLanding="GBR" landingPortCode="GBADR">
        <salesline speciesCode="NEP" faoAreaCode="27" ZoneCode="VB1" disposalCode="HCN" freshnessCode="A" sizeCode="2" presentationCode="HEA" stateCode="FRE" numberOfFish="" weightKgs="52" value="765" currencyCode="GBP" withdrawnDestinationCode="OTH" buyerReg="201" salesContractRef="B4123"/>
        <salesline speciesCode="WHB" faoAreaCode="27" ZoneCode="VB2" disposalCode="HCN" freshnessCode="A" sizeCode="3" presentationCode="GHT" stateCode="FRE" numberOfFish="" weightKgs="12" value="55" currencyCode="EUR" withdrawnDestinationCode="BOL" buyerReg="201" salesContractRef="TT45687"/>
        <salesline speciesCode="JAD" faoAreaCode="27" ZoneCode="VIID" disposalCode="COV" freshnessCode="C" sizeCode="2" presentationCode="FIL" stateCode="FRE" numberOfFish="" weightKgs="300" value="330" currencyCode="GBP" withdrawnDestinationCode="GIF" buyerReg="201" salesContractRef="B5687"/>
    </salesnote>
</ers>

最終的に System.ServiceModel.FaultExceptionio'1' が表示され、追加のメッセージが表示されます。@String は正確に 1 文字の長さでなければなりません。

エラーは、以下の関数の returnEditor.text 行でスローされます。

Dim value As String = File.ReadAllText("C:\Users\Public\Documents\View to Learn\SNADD.xml")

        Using ters As New ErsTestSite.ERSAPIServiceClient
            ters.Open()
            returnsEditor.Text = ters.salesXMLCheck(value)
            ters.Close()
        End Using

関数のパラメータとして「Hello」を代入すると、明らかにサービス接続が機能するか、同じメッセージがスローされますが、有効な xml を送信しようとするとこのエラーがスローされるのはなぜですか?

編集

スタック トレースをよく見ると、次のように表示されます。

   at System.Convert.ToChar(String value, IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at System.Data.Linq.DBConvert.ChangeType(Object value, Type type)
   at Read_FreshnessGrade(ObjectMaterializer`1 )
   at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ERSAPIService.Helper.SalesNoteHelper.SalesNoteCheck(XDocument xlowerDocument, XDocument xmlOutput, String rootName, String userId) in C:\Users\ravneet.sodhi\Desktop\ERSAPIService\ERSAPIService\Helper\SalesNoteHelper.cs:line 262
   at ERSAPIService.Helper.SalesNoteHelper.salesXMLCheck(String xmlString) in C:\Users\ravneet.sodhi\Desktop\ERSAPIService\ERSAPIService\Helper\SalesNoteHelper.cs:line 71
   at ERSAPIService.ERSAPIService.salesXMLCheck(String xmlString) in C:\Users\ravneet.sodhi\Desktop\ERSAPIService\ERSAPIService\ERSAPIService.svc.cs:line 1776

私は間違いなくraveet.sodhiではないので、これはxmlが実際に相手側に正常に渡されているが、サービスに問題があることを意味しますか?

4

1 に答える 1

1

私は間違いなくraveet.sodhiではないので、これはxmlが実際に相手側に正常に渡されているが、サービスに問題があることを意味しますか?

はい、サービスを問題なく呼び出しました。

サービスはLINQ to SQLを使用しているようで、どこかでCharフィールドを使用する必要がありStringます。

于 2015-06-10T08:00:00.737 に答える