?
Solved

Value cannot be null. Parameter name s.. error after successfull web service call

Posted on 2007-10-12
20
Medium Priority
?
9,613 Views
Last Modified: 2013-11-18
The param the web service host is complainnig about is definately present in the call (I debugged the client script which calls the Ws- and sure enough the string param can be seen in the soap:body section of the SOAP request). For some weird reason, the string parameter is never making it to the web service- the web service just gets a null value(!?).

Does anyone know why this might be. I am utterly confused. (Debug tips, etc.?).

Thanks in advance,

oddic
0
Comment
Question by:OddiC
  • 10
  • 7
  • 2
  • +1
20 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20068341
Are you sure that the proxy is in sync with the web service? can you regenerate the proxy and try it again?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20068408
There is a possibility that the parameter is there allright,
but that you put it in the wrong namespace, so the service doesn't see it
0
 

Author Comment

by:OddiC
ID: 20068541
Gertone- you are correct. Here is my dilemma. The xmlns that the service expects is:

<soap:Body>
        <Create xmlns="https://services.experts.com:448/">
        <xml>xmlString</xml>
        </Create>
</soap:Body>'

However, when I try to use that the service fails becuase the xmlns above is not accesible by the server hosting the web service! (it is only accessible externally- to access the same resources on the server internally you can only use: http://[servername]:81 ...

When I created the web service in VS2005, I specified the above xmlns as the service namespace. When I try to change it, the web service call fails. Is my only option to somehow get my network admin to make the xmlns URL accessible internally?


Sorry so long, but, I think you have hit the issue on the head- now I just gotta fix it!


Thanks in advance!!!!!!

-oddic
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:dstanley9
ID: 20068561
The namespace does not need to actually resolve to anything - it is just use to uniquely identify the namespace that the service is in.  
0
 

Author Comment

by:OddiC
ID: 20068604
Hmmmm. I'm wondering then, why when I changed the namespace attribute in the asmx.cs file, recompiled and re-published, and used this new namespace instead of the one that wasn't working- the web service failed?

So just to clarify- can I use the same unique (not resolving to anything) namespace for my SOAPAction header, my xmlns attribute of my soap:Body param, AND my .NET service namespace?

I just need to tie everything together....
0
 
LVL 25

Expert Comment

by:dstanley9
ID: 20068657
change the namespace within the service you'll need to re-reference it on the client so the proxy uses the correct namespace.  The client namespace can be totally different, but the namespace of the service is used by the generated proxy behind the scenes.

As far as using the same namespace within the service - I'm not a SOAP expert but I believe that you can.  It doesn't have to match the code's internal .NET namespace either.  

I typically use a namespace that includes the name of the company, the application, and the method name (e.g. http:\\www.mycompany.com\myapp\mymethod).  It doesn't even have to be a valid URL let alone resolve to anything.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20068717
<soap:Body>
        <Create xmlns="https://services.experts.com:448/">
        <xml>xmlString</xml>
        </Create>
</soap:Body>

in this example Create and xml are in the "https://services.experts.com:448/" namespace
(the https... part is a simple unique string that took the url form, because when you take your own domain in the name, chances are small someone else will ever pick the same unique ID)

The webservice defines which amespaces are required

Likely the parameters have a different namespace and the service is expecting that
<soap:Body>
        <Create xmlns="https://services.experts.com:448/">
        <xml xmlns="https://anotherservice.experts.com:448>xmlString</xml>
        </Create>
</soap:Body>

Try to find an example of a working envelope, or look in the wsdl

cheers

Geert
0
 

Author Comment

by:OddiC
ID: 20068944
Ok here is what I did (and the web service still works, but (drat!) still will not accept the string parameter it expects.

1). Changed the namespace of the web service a la:
[WebService(Namespace = "http://webservices.mycompany.com/test99/Ws/")]

2). I changed the calling script on the client in two places:
   2a). I changed SOAPAction= 'http://webservices.mycompany.mydept.test99.com/MyWebMethod'
   2b). I changed the xmlns attribute of the <Create.. tag to:  

<Create xmlns="http://webservices.mycompany.com/test99/Ws/">



Is that all that is needed technically?

PS (BIG PS- May be the root of my prblem...): the web service is accessed via https over port 448. Everything above *almost* works, but the service fails because it cannot access the xmlns namespace. I removed the xmlns attribute and the call went through, but (obviously) once again, the web service could not find the string parameter.

Is there something special I need to do to make my non-resolving, unique Ws namespace accessible over 488 traffic? (I tried just adding https and :448... but that didn't budge).

Do I need to do something in IIS?



The service fails everytime I try to specify the xmlns attribute- even if it matches the namespace I gave the .NET web service. (??)


Thanks a ton in advance (I am almost there!)



     
0
 

Author Comment

by:OddiC
ID: 20069182
Without fail- if I specify the correct xmlns, the service call fails (return code 400). But if I omit the xmlns, or ste it to anything that isn't the real namespace of the service, the call goes through, but can't find the parameter. Uggh!

Does anyone know what in the heck could be going on? My SOAPAction is set to the correct namespace and it seems to have no problem with that. It's just this darn xmlns attribute in the soap:Body that is tripping everything up (and nullifying the string parameter I am sending to my web service).



All suggestions, hints, tips, links, encouragement, (lol) is very welcome.

Thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20069346
have you tried
<soap:Body>
        <Create>
        <xml xmlns="find the correct namespace here">xmlString</xml>
        </Create>
</soap:Body>

so only the parameter itself gets a namespace
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20069350
is this a public webservice you are accessing?
maybe we can derive something from the wsdl
0
 

Author Comment

by:OddiC
ID: 20069414
That still did not work- the call succeeded (better than other times when I put proper xmlns into the parent of the xml param), but the service still could not find the string param. Here is the WSDL:

((the web method is CreateObj (renamed to protect confidential info)):


  <?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://webservices.xyz12307.com/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://webservices.xyz12307.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://webservices.xyz12307.com/">
- <s:element name="Hello">
  <s:complexType />
  </s:element>
- <s:element name="HelloResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="HelloResult" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="EventLogTest">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="msg" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="ltype" type="tns:EventLogEntryType" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:simpleType name="EventLogEntryType">
- <s:restriction base="s:string">
  <s:enumeration value="Error" />
  <s:enumeration value="Warning" />
  <s:enumeration value="Information" />
  <s:enumeration value="SuccessAudit" />
  <s:enumeration value="FailureAudit" />
  </s:restriction>
  </s:simpleType>
- <s:element name="EventLogTestResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="EventLogTestResult" type="s:int" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="CreateObj">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="xmlDeals" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="CreateObjResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="CreateObjResult" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="CreateDataClient">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="clientName" type="s:string" />
  <s:element minOccurs="1" maxOccurs="1" name="clientID" type="s:int" />
  </s:sequence>
  </s:complexType>
  </s:element>
- <s:element name="CreateDataClientResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="1" maxOccurs="1" name="CreateDataClientResult" type="s:int" />
  </s:sequence>
  </s:complexType>
  </s:element>
  </s:schema>
  </wsdl:types>
- <wsdl:message name="HelloSoapIn">
  <wsdl:part name="parameters" element="tns:Hello" />
  </wsdl:message>
- <wsdl:message name="HelloSoapOut">
  <wsdl:part name="parameters" element="tns:HelloResponse" />
  </wsdl:message>
- <wsdl:message name="EventLogTestSoapIn">
  <wsdl:part name="parameters" element="tns:EventLogTest" />
  </wsdl:message>
- <wsdl:message name="EventLogTestSoapOut">
  <wsdl:part name="parameters" element="tns:EventLogTestResponse" />
  </wsdl:message>
- <wsdl:message name="CreateObjSoapIn">
  <wsdl:part name="parameters" element="tns:CreateObj" />
  </wsdl:message>
- <wsdl:message name="CreateObjSoapOut">
  <wsdl:part name="parameters" element="tns:CreateObjResponse" />
  </wsdl:message>
- <wsdl:message name="CreateDataClientSoapIn">
  <wsdl:part name="parameters" element="tns:CreateDataClient" />
  </wsdl:message>
- <wsdl:message name="CreateDataClientSoapOut">
  <wsdl:part name="parameters" element="tns:CreateDataClientResponse" />
  </wsdl:message>
- <wsdl:portType name="DataServiceSoap">
- <wsdl:operation name="Hello">
  <wsdl:input message="tns:HelloSoapIn" />
  <wsdl:output message="tns:HelloSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="EventLogTest">
  <wsdl:input message="tns:EventLogTestSoapIn" />
  <wsdl:output message="tns:EventLogTestSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="CreateObj">
  <wsdl:input message="tns:CreateObjSoapIn" />
  <wsdl:output message="tns:CreateObjSoapOut" />
  </wsdl:operation>
- <wsdl:operation name="CreateDataClient">
  <wsdl:input message="tns:CreateDataClientSoapIn" />
  <wsdl:output message="tns:CreateDataClientSoapOut" />
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="DataServiceSoap" type="tns:DataServiceSoap">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Hello">
  <soap:operation soapAction="http://webservices.xyz12307.com/Hello" style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="EventLogTest">
  <soap:operation soapAction="http://webservices.xyz12307.com/EventLogTest" style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="CreateObj">
  <soap:operation soapAction="http://webservices.xyz12307.com/CreateObj" style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="CreateDataClient">
  <soap:operation soapAction="http://webservices.xyz12307.com/CreateDataClient" style="document" />
- <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:binding name="DataServiceSoap12" type="tns:DataServiceSoap">
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Hello">
  <soap12:operation soapAction="http://webservices.xyz12307.com/Hello" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="EventLogTest">
  <soap12:operation soapAction="http://webservices.xyz12307.com/EventLogTest" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="CreateObj">
  <soap12:operation soapAction="http://webservices.xyz12307.com/CreateObj" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="CreateDataClient">
  <soap12:operation soapAction="http://webservices.xyz12307.com/CreateDataClient" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="DataService">
- <wsdl:port name="DataServiceSoap" binding="tns:DataServiceSoap">
  <soap:address location="https://mdmcsxdev3.mdmc.com:448/DATAWebService/DataService.asmx" />
  </wsdl:port>
- <wsdl:port name="DataServiceSoap12" binding="tns:DataServiceSoap12">
  <soap12:address location="https://mdmcsxdev3.mdmc.com:448/DATAWebService/DataService.asmx" />
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
0
 

Author Comment

by:OddiC
ID: 20069424
Any thoughts?
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 20070508
According to the WSDL, this is a correct envelope

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <CreateObj xmlns="http://webservices.xyz12307.com/">
            <xmlDeals>STRING</xmlDeals>
        </CreateObj>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

so CreateObj should be in the xyz123... namespace
and the argument should be <xmlDeals> in the same namespace
the prefix doesn't matter
so "soap" is as good as SOAP-ENV

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body>
        <CreateObj xmlns="http://webservices.xyz12307.com/">
            <xmlDeals>STRING</xmlDeals>
        </CreateObj>
    </soap:Body>
</soap:Envelope>

will work the same,
I guess the element name was the problem, not the namespace
0
 

Author Comment

by:OddiC
ID: 20077794
Would changing the web service namespace require a restart of IIS? I have adhered to the exact SOAP envelope requirements, but, still my string parameter will not pass into the web service. The eror on the hosting server says:

Value cannot be null.
Parameter name: s

Refering to my xmlDeals string parameter...
0
 

Author Comment

by:OddiC
ID: 20078677
Many, many thanks for all of your assistance on this, Gertone. I finally figure out the problem! The issue was not the xmlns, nor the element name (I had used several variations in theis thread (not in accordance with the WSDL) to mask private info of my client. The failure was due to my string parameter being xml syntax (the parser was failing as it was interpreting this string parameter as different (additional, unexpected) elements of the SOAP envelope.

All is well now! I really appreciate your help- you definately guided me in the right direction.

-oddic
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20078686
welcome
0
 

Author Comment

by:OddiC
ID: 20079387
Oh and just for future developer reference- I was able to stop this problematic interpretation of the xml parameter by using <![CDATA ... ]]> to escape the xml processing.

Hope this helps someone with this same issue!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 20079480
That makes sense
every < in a CDATA section will not be interpreted as the start of a tag (making the parameter no longer a string) but as a "<" sign in text
this way you made a string from the nested XML
"are you sure you are passing a string?" would have been my next question
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question