Link to home
Create AccountLog in
.NET Programming

.NET Programming

--

Questions

--

Followers

Top Experts

Avatar of OddiC
OddiC

Value cannot be null. Parameter name s.. error after successfull web service call
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

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of surajgupthasurajguptha🇺🇸

Are you sure that the proxy is in sync with the web service? can you regenerate the proxy and try it again?

Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

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

Avatar of OddiCOddiC

ASKER

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

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


The namespace does not need to actually resolve to anything - it is just use to uniquely identify the namespace that the service is in.  

Avatar of OddiCOddiC

ASKER

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....

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.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

<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

Avatar of OddiCOddiC

ASKER

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!)



     

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of OddiCOddiC

ASKER

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

Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

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

Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

is this a public webservice you are accessing?
maybe we can derive something from the wsdl

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of OddiCOddiC

ASKER

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>

Avatar of OddiCOddiC

ASKER

Any thoughts?

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of OddiCOddiC

ASKER

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...

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of OddiCOddiC

ASKER

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

Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

welcome

Avatar of OddiCOddiC

ASKER

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!

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Gertone (Geert Bormans)Gertone (Geert Bormans)🇧🇪

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
.NET Programming

.NET Programming

--

Questions

--

Followers

Top Experts

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.